public static void InsertOrUpdateDistributor(CanonDistributor newValue) { CanonDataContext db = Cdb.Instance; Distributor distributor = null; if (newValue.ID == -1) { distributor = new Distributor(); db.Distributors.InsertOnSubmit(distributor); } else { distributor = db.Distributors.FirstOrDefault(d => d.ID == newValue.ID); } distributor.FileAs = newValue.FileAs; distributor.IDDistributorType = newValue.IDDistributorType; distributor.Note = newValue.Note; distributor.ShowInImports = newValue.ShowInImports; distributor.ShowInReports = newValue.ShowInReports; db.SubmitChanges(); }
public static void InsertOrUpdateDistributor(CanonDistributor newValue) { CanonDataContext db = Cdb.Instance; Distributor distributor = null; if (newValue.ID == -1) { distributor = new Distributor(); db.Distributors.InsertOnSubmit(distributor); } else { distributor = db.Distributors.FirstOrDefault(d => d.ID == newValue.ID); } distributor.FileAs = newValue.FileAs; distributor.IDDistributorType = newValue.IDDistributorType; distributor.Note = newValue.Note; distributor.ShowInImports = newValue.ShowInImports; distributor.ShowInReports = newValue.ShowInReports; db.SubmitChanges(); }
protected void gridDistributorsManage_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { try { SessionManager.IsEditFormCreated = false; CanonDistributor cd = new CanonDistributor(); cd.ID = int.Parse(e.Keys[0].ToString()); cd.FileAs = e.NewValues["FileAs"].ToString(); cd.IDDistributorType = int.Parse(Utilities.GetEditFormComboValue(gridDistributorsManage, "cboType").ToString()); cd.Note = e.NewValues["Note"].ToString(); cd.ShowInImports = bool.Parse(e.NewValues["ShowInImports"].ToString()); cd.ShowInReports = bool.Parse(e.NewValues["ShowInReports"].ToString()); CanonDistributor.InsertOrUpdateDistributor(cd); e.Cancel = true; gridDistributorsManage.CancelEdit(); this.BindData(); } catch (Exception ex) { Logger.Log(string.Format("exception {0}", ex.ToString()), LogLevel.Error); } }