public static BusinessObjects.Client GetClient(string clientid) { DataTable dt = new DataTable(); BusinessObjects.Client c = new BusinessObjects.Client(); string sql = @"SELECT rtrim(ID) ID, TYPE, NAME,[Contact],[Phone],[Fax],[ReferenceNo] FROM CLIENT_DAT WHERE ID=?"; using (OdbcDataAdapter adp = new OdbcDataAdapter(sql, Properties.Settings.Default.IESDBConn)) { adp.SelectCommand.Parameters.Add(new OdbcParameter("@clientid", clientid)); adp.Fill(dt); } if (dt.Rows.Count > 0) { c.ClientID = dt.Rows[0]["ID"].ToString(); c.Type = dt.Rows[0]["TYPE"].ToString(); c.Name = dt.Rows[0]["NAME"].ToString(); c.Contact = dt.Rows[0]["Contact"].ToString(); c.Phone = dt.Rows[0]["Phone"].ToString(); c.Fax = dt.Rows[0]["Fax"].ToString(); c.ReferenceNo = dt.Rows[0]["ReferenceNo"].ToString(); return c; } return null; }
protected void SuperForm1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e) { SqlDataSource src = new SqlDataSource(); if (OboutDropDownList1.SelectedValue == "Clients") { BusinessObjects.Client c = new BusinessObjects.Client(); c.ClientID = e.NewValues["ID"].ToString(); c.Type = e.NewValues["Type"].ToString(); c.Name = e.NewValues["Name"].ToString(); c.Contact = e.NewValues["Contact"].ToString(); c.Phone = e.NewValues["Phone"].ToString(); c.Fax = e.NewValues["Fax"].ToString(); c.ReferenceNo = e.NewValues["ReferenceNo"].ToString(); Functions.DB.SaveClient(c); ID = e.NewValues["ID"].ToString(); } else if (OboutDropDownList1.SelectedValue == "Sales Reps") { BusinessObjects.SalesRep s = new BusinessObjects.SalesRep(); int id; int.TryParse(e.NewValues["ID"].ToString(),out id); s.ID = id; s.Code = e.NewValues["Code"].ToString(); s.Name = e.NewValues["Name"].ToString(); bool act; bool.TryParse(e.NewValues["Active"].ToString(),out act); s.Active = act; Functions.DB.SaveSalesRep(s); ID = e.NewValues["ID"].ToString(); } bindgrid(); }