public class BillPara
{
public string paraid { get; set; }
public string description { get; set; }
public string enterby { get; set; }
public string enterdate { get; set; }
public string updateby { get; set; }
public string updatedate { get; set; }
}
==========================================
static private void SetData(ref List<BillPara> lst, string paraid, string description, string enterby,
string enterdate, string updateby, string updatedate)
{
BillPara bill = new BillPara();
bill.paraid = paraid;
bill.description = description;
bill.enterby = enterby;
bill.enterdate = enterdate;
bill.updateby = updateby;
bill.updatedate = updatedate;
lst.Add(bill);
}
========================================
[WebMethod]
static public List<BillPara> updatedata(string id, string desc, string enterby)
{
//string result = "";
List<BillPara> lstbill = new List<BillPara>();
OracleConnection cn = new OracleConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
try
{
HttpContext ct = HttpContext.Current; ;
//ct.Response.Write(ct.Session["a"].ToString());
if (cn.State != ConnectionState.Open)
cn.Open();
OracleCommand cm = new OracleCommand("", cn);
if (enterby == "")
{
cm.CommandText = " SELECT get_maxid('id_hf_bill_disallowances','bd_id') from dual ";
string maxid = cm.ExecuteScalar().ToString();
cm.CommandText = " INSERT INTO id_hf_bill_disallowances" +
" (bd_id, bd_desc, bd_enter_by, bd_enter_date) VALUES" +
" (:bd_id, :bd_desc, :bd_enter_by, sysdate) ";
cm.Parameters.Clear();
cm.Parameters.AddWithValue(":bd_id", maxid);
cm.Parameters.AddWithValue(":bd_desc", desc);
cm.Parameters.AddWithValue(":bd_enter_by", ct.Session["USERNAME"].ToString());
int i = cm.ExecuteNonQuery();
if (i > 0)
{
SetData(ref lstbill, maxid, "", ct.Session["USERNAME"].ToString(), DateTime.Now.ToString("M/d/yyyy hh:mm:ss tt"), "", "");
}
}
else
{
cm.CommandText = " UPDATE id_hf_bill_disallowances SET" +
" bd_desc = :bd_desc, bd_update_by = :bd_update_by, bd_update_date = sysdate" +
" WHERE bd_id = :bd_id";
cm.Parameters.Clear();
cm.Parameters.AddWithValue(":bd_id", id);
cm.Parameters.AddWithValue(":bd_desc", desc);
cm.Parameters.AddWithValue(":bd_update_by", ct.Session["USERNAME"].ToString());
int i = cm.ExecuteNonQuery();
if (i > 0)
{
SetData(ref lstbill, id, "", "", "", ct.Session["USERNAME"].ToString(), DateTime.Now.ToString("M/d/yyyy hh:mm:ss tt"));
}
}
}
catch (Exception ex)
{
SetData(ref lstbill, "Error : " + ex.Message, "", "", "", "", "");
Elmah.ErrorLog.GetDefault(HttpContext.Current).Log(new Elmah.Error(ex, HttpContext.Current));
}
finally
{
if (cn.State != ConnectionState.Closed)
cn.Close();
}
return lstbill;
}
{
public string paraid { get; set; }
public string description { get; set; }
public string enterby { get; set; }
public string enterdate { get; set; }
public string updateby { get; set; }
public string updatedate { get; set; }
}
==========================================
static private void SetData(ref List<BillPara> lst, string paraid, string description, string enterby,
string enterdate, string updateby, string updatedate)
{
BillPara bill = new BillPara();
bill.paraid = paraid;
bill.description = description;
bill.enterby = enterby;
bill.enterdate = enterdate;
bill.updateby = updateby;
bill.updatedate = updatedate;
lst.Add(bill);
}
========================================
[WebMethod]
static public List<BillPara> updatedata(string id, string desc, string enterby)
{
//string result = "";
List<BillPara> lstbill = new List<BillPara>();
OracleConnection cn = new OracleConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
try
{
HttpContext ct = HttpContext.Current; ;
//ct.Response.Write(ct.Session["a"].ToString());
if (cn.State != ConnectionState.Open)
cn.Open();
OracleCommand cm = new OracleCommand("", cn);
if (enterby == "")
{
cm.CommandText = " SELECT get_maxid('id_hf_bill_disallowances','bd_id') from dual ";
string maxid = cm.ExecuteScalar().ToString();
cm.CommandText = " INSERT INTO id_hf_bill_disallowances" +
" (bd_id, bd_desc, bd_enter_by, bd_enter_date) VALUES" +
" (:bd_id, :bd_desc, :bd_enter_by, sysdate) ";
cm.Parameters.Clear();
cm.Parameters.AddWithValue(":bd_id", maxid);
cm.Parameters.AddWithValue(":bd_desc", desc);
cm.Parameters.AddWithValue(":bd_enter_by", ct.Session["USERNAME"].ToString());
int i = cm.ExecuteNonQuery();
if (i > 0)
{
SetData(ref lstbill, maxid, "", ct.Session["USERNAME"].ToString(), DateTime.Now.ToString("M/d/yyyy hh:mm:ss tt"), "", "");
}
}
else
{
cm.CommandText = " UPDATE id_hf_bill_disallowances SET" +
" bd_desc = :bd_desc, bd_update_by = :bd_update_by, bd_update_date = sysdate" +
" WHERE bd_id = :bd_id";
cm.Parameters.Clear();
cm.Parameters.AddWithValue(":bd_id", id);
cm.Parameters.AddWithValue(":bd_desc", desc);
cm.Parameters.AddWithValue(":bd_update_by", ct.Session["USERNAME"].ToString());
int i = cm.ExecuteNonQuery();
if (i > 0)
{
SetData(ref lstbill, id, "", "", "", ct.Session["USERNAME"].ToString(), DateTime.Now.ToString("M/d/yyyy hh:mm:ss tt"));
}
}
}
catch (Exception ex)
{
SetData(ref lstbill, "Error : " + ex.Message, "", "", "", "", "");
Elmah.ErrorLog.GetDefault(HttpContext.Current).Log(new Elmah.Error(ex, HttpContext.Current));
}
finally
{
if (cn.State != ConnectionState.Closed)
cn.Close();
}
return lstbill;
}
No comments:
Post a Comment