public override void Save() { if (string.IsNullOrEmpty(Txt_name.Text)) { Txt_name.ErrorText = "يرجى إدخال اسم الخزنة !"; return; } else { var db = new SalesDataContext(); accounts Account; if (Treasury.id == 0) { Action = "Insert"; Account = new accounts(); db.treasurys.InsertOnSubmit(Treasury); db.accounts.InsertOnSubmit(Account); } else { Action = "Update"; db.treasurys.Attach(Treasury); Account = db.accounts.Single(S => S.id == Treasury.account_id); } SetData(); Account.name = Treasury.name; db.SubmitChanges(); Treasury.account_id = Account.id; db.SubmitChanges(); Txt_name.Text = string.Empty; Txt_name.Focus(); base.Save(); } }
public override void Save() { if (string.IsNullOrEmpty(Txt_name.Text)) { Txt_name.ErrorText = "يرجى إدخال اسم المخزن !"; return; } else { var db = new SalesDataContext(); if (Store.id == 0) { Action = "Insert"; db.stores.InsertOnSubmit(Store); } else { Action = "Update"; db.stores.Attach(Store); } SetData(); db.SubmitChanges(); base.Save(); Txt_name.Text = string.Empty; Txt_name.Focus(); } }
public override void Save() { if (IsEmpty() == false) { return; } else { var db = new SalesDataContext(); if (categoy.id == 0) { Action = "Insert"; db.product_categories.InsertOnSubmit(categoy); } else { Action = "Update"; db.product_categories.Attach(categoy); } SetData(); db.SubmitChanges(); Txt_Name.Text = string.Empty; Txt_Name.Focus(); base.Save(); } }
public override void Save() { if (string.IsNullOrEmpty(Txt_Name.Text)) { Txt_Name.ErrorText = "يرجى إدخال اسم الشركة !"; return; } else { using (SalesDataContext db = new SalesDataContext()) { Action = "Update"; company_info Company = db.company_info.FirstOrDefault(); if (Company == null) { Company = new company_info(); db.company_info.InsertOnSubmit(Company); Action = "Insetr"; } Company.company_name = Txt_Name.Text; Company.company_address = Txt_Address.Text; Company.company_email = Txt_Email.Text; Company.company_mobile = Txt_Phone.Text; //Company.company_account = Txt_Account.Text; //Company.company_vatnumber = Txt_VatNumber.Text; //Company.companu_logo = Pic_Logo.Image; db.SubmitChanges(); } } base.Save(); }
public override void New() { Product = new products() { code = GetNewProductCode(), status = true, }; base.New(); var data = dgv.DataSource as BindingList <products_units>; var db = new SalesDataContext(); if (db.units.Count() == 0) { db.units.InsertOnSubmit(new units() { name = "قطعة" }); db.SubmitChanges(); RefreshData(); } Text = $"إضافة صنف جديد"; data.Add(new products_units() { factor = 1, unitid = db.units.First().id, barcode = Master.GetNextNumberInString("00000000") }); }
private void Txt_Category_ProcessNewValue(object sender, DevExpress.XtraEditors.Controls.ProcessNewValueEventArgs e) { if (e.DisplayValue is string st && st.Trim() != string.Empty) { var newObject = new product_categories() { name = st, parent_id = 0, number = "0" }; using (SalesDataContext db = new SalesDataContext()) { db.product_categories.InsertOnSubmit(newObject); db.SubmitChanges(); } ((List <product_categories>)Txt_Category.Properties.DataSource).Add(newObject); e.Handled = true; } }
private void UpEdit_ProcessNewValue(object sender, DevExpress.XtraEditors.Controls.ProcessNewValueEventArgs e) { if (e.DisplayValue is string st && st.Trim() != string.Empty) { var newObject = new units() { name = st.Trim() }; using (SalesDataContext db = new SalesDataContext()) { db.units.InsertOnSubmit(newObject); db.SubmitChanges(); } ((List <units>)upEdit.DataSource).Add(newObject); ((List <units>)(((LookUpEdit)sender).Properties.DataSource)).Add(newObject); e.Handled = true; } }
public override void Save() { if (IsEmpty() == false) { return; } else { var db = new SalesDataContext(); accounts Account; if (Cust_Supp.id == 0) { Action = "Insert"; db.customers_suppliers.InsertOnSubmit(Cust_Supp); Account = new accounts(); db.accounts.InsertOnSubmit(Account); } else { Action = "Update"; db.customers_suppliers.Attach(Cust_Supp); Account = db.accounts.First(S => S.id == Cust_Supp.account_id); } SetData(); Account.name = Cust_Supp.name; //db.SubmitChanges(); Cust_Supp.account_id = Account.id; db.SubmitChanges(); //Txt_Name.Text = string.Empty; //Txt_Address.Text = string.Empty; //Txt_Mobile.Text = string.Empty; //Txt_Email.Text = string.Empty; //Txt_Name.Focus(); base.Save(); } }
public override void Save() { if (ValidateData() == false) { return; } using (SalesDataContext db = new SalesDataContext()) { switch (Product.id) { case 0: Action = "Insert"; db.products.InsertOnSubmit(Product); break; default: Action = "Update"; db.products.Attach(Product); break; } SetData(); db.SubmitChanges(); var data = dgv.DataSource as BindingList <products_units>; foreach (var item in data) { item.productid = Product.id; if (string.IsNullOrEmpty(item.barcode)) { item.barcode = ""; } } sdb.SubmitChanges(); } base.Save(); }