public override void Save() { if (!IsDataValidated()) { return; } var db = new DAL.dbDataContext(); DAL.Account account; if (cusVendor.ID == 0) { db.CustomersAndVendors.InsertOnSubmit(cusVendor); account = new DAL.Account(); db.Accounts.InsertOnSubmit(account); } else { db.CustomersAndVendors.Attach(cusVendor); account = db.Accounts.Single(s => s.ID == cusVendor.AccountID); } SetData(); account.Name = cusVendor.Name; db.SubmitChanges(); cusVendor.AccountID = account.ID; db.SubmitChanges(); base.Save(); }
private void btnDelete_Click_1(object sender, EventArgs e) { if (DGV_stores.Rows.Count > 0) { if (DGV_stores.SelectedRows != null) { int id = Convert.ToInt32(DGV_stores.CurrentRow.Cells[0].Value.ToString()); unit = db.unites.Where(u => u.id == id).FirstOrDefault(); if (unit.movements.Count > 0) { MessageBox.Show("لا يمكن حذف الوحدة حيث تم استخدامها في ععمليات من قبل ومسحها سيؤدي لتلف بعض البيانات"); return; } db.unites.DeleteOnSubmit(unit); db.SubmitChanges(); New(); btnDelete.Enabled = false; MessageBox.Show("تم حذف الوحدة بنجاح"); db = new DAL.dbDataContext(); DGV_stores.DataSource = db.unites; DGV_stores.Columns["id"].Visible = false; DGV_stores.Columns["name"].HeaderText = "الاسم"; return; } } }
public override void Save() { if (txt_Name.Text.Trim() == String.Empty) { txt_Name.ErrorText = "برجاء ادخال اسم الخزنة"; return; } var db = new DAL.dbDataContext(); DAL.Account account; if (drawer.ID == 0) { account = new DAL.Account(); db.Drawers.InsertOnSubmit(drawer); db.Accounts.InsertOnSubmit(account); } else { db.Drawers.Attach(drawer); account = db.Accounts.Single(s => s.ID == drawer.AccountID); } SetData(); account.Name = drawer.Name; db.SubmitChanges(); drawer.AccountID = account.ID; db.SubmitChanges(); base.Save(); }
public override void GetData() { lkp_Branch.EditValue = invoice.Branch; lkp_Drawer.EditValue = invoice.Drawer; lkp_PartType.EditValue = invoice.PartType; glkp_PartID.EditValue = invoice.PartID; txt_Code.Text = invoice.Code; dt_Date.DateTime = invoice.Date; dt_DelivaryDate.EditValue = invoice.DeliveryDate; dt_PostDate.EditValue = invoice.PostDate; memoEme_ShoppingAddress.Text = invoice.ShippingAddress; me_Notes.Text = invoice.Notes; chk_PostToStore.Checked = invoice.PostedToStore; spn_DiscountRation.EditValue = invoice.DiscountRation; spn_DiscountValue.EditValue = invoice.DiscountVale; spn_Expences.EditValue = invoice.Expences; spn_Net.EditValue = invoice.Net; spn_Paid.EditValue = invoice.Paid; spn_Remaing.EditValue = invoice.Remaining; spn_Tax.EditValue = invoice.Tax; spn_TaxValue.EditValue = invoice.TaxValue; spn_Total.EditValue = invoice.Total; generalDB = new DAL.dbDataContext(); gridControl1.DataSource = generalDB.InvoiceDetails.Where(x => x.InvoiceID == invoice.ID); base.GetData(); }
void save() { if (txtName.Text.Trim() == string.Empty || txtPass.Text.Trim() == string.Empty || txtUser.Text.Trim() == string.Empty) { MessageBox.Show("الرجاء عدم ترك حقول فارغة"); return; } if (user.id == 0) { db = new DAL.dbDataContext(); db.users.InsertOnSubmit(user); SetData(); db.SubmitChanges(); } else { SetData(); db.SubmitChanges(); } MessageBox.Show("تم الحفظ بنجاح"); dgvUsers.DataSource = db.users; New(); }
public override void Save() { gridView1.UpdateCurrentRow(); if (ValdiateData() == false) { return; } var db = new DAL.dbDataContext(); if (product.ID == 0) { db.Products.InsertOnSubmit(product); } else { db.Products.Attach(product); } SetData(); db.SubmitChanges(); var data = gridView1.DataSource as BindingList <DAL.ProductUnit>; foreach (var item in data) { item.ProductID = product.ID; if (string.IsNullOrEmpty(item.Barcode)) { item.Barcode = ""; } } sdb.SubmitChanges(); base.Save(); this.Text = string.Format("بيانات صنف : {0}", product.Name); }
public override void New() { product = new DAL.Product() { Code = GetNewProductCode(), IsActive = true }; var db = new DAL.dbDataContext(); var categ = db.ProductCategories.Where(x => db.ProductCategories.Where(w => w.ParentID == x.ID).Count() == 0).FirstOrDefault(); if (categ != null) { product.CategoryID = categ.ID; } base.New(); this.Text = "اضافه صنف جديد"; var data = gridView1.DataSource as BindingList <DAL.ProductUnit>; if (db.UnitNames.Count() == 0) { db.UnitNames.InsertOnSubmit(new DAL.UnitName() { Name = "قطعة" }); db.SubmitChanges(); RefreshData(); } data.Add(new DAL.ProductUnit() { factor = 1, UnitID = db.UnitNames.First().ID, Barcode = GetNewBarCode() }); }
void save() { if (Cmb_stores.SelectedValue == null) { MessageBox.Show("الرجاء اختيار مخزن"); return; } var db = new DAL.dbDataContext(); if (movement_header.id == 0) { movement_header = new DAL.movements_header(); db.movements_headers.InsertOnSubmit(movement_header); SetData(); db.SubmitChanges(); } foreach (DataGridViewRow row in dgvItems.Rows) { movement = new DAL.movement(); movement.movements_header = movement_header; movement.item_id = Convert.ToInt32(row.Cells["item_id"].Value); movement.unit_id = Convert.ToInt32(row.Cells["unit_id"].Value); movement.qty = Convert.ToDecimal(row.Cells["qty"].Value); //movement.qty_unit = Convert.ToDecimal(row.Cells["unit_qty"].Value); db.movements.InsertOnSubmit(movement); db.SubmitChanges(); } MessageBox.Show("تم الحفظ بنجاح"); New(); }
public Frm_Stores(int id) { InitializeComponent(); var db = new DAL.dbDataContext(); store = db.Stores.Where(s => s.ID == id).First(); GetData(); }
void LoadDrawer(int id) { using (var db = new DAL.dbDataContext()) { drawer = db.Drawers.Single(s => s.ID == id); GetData(); } }
public override void RefreshData() { using (var db = new DAL.dbDataContext()) { gridControl1.DataSource = db.Drawers.ToList(); } base.RefreshData(); }
public override void RefreshData() { using (var db = new DAL.dbDataContext()) { gridControl1.DataSource = (isCustomer) ? Session.Customers.ToList() : Session.Vendors.ToList(); } base.RefreshData(); }
public override void RefreshData() { using (var db = new DAL.dbDataContext()) { lkp_Category.Properties.DataSource = db.ProductCategories.Where(x => db.ProductCategories.Where(w => w.ParentID == x.ID).Count() == 0).ToList(); repoUOM.DataSource = db.UnitNames.ToList(); } base.RefreshData(); }
private void LoadObject(int id) { using (var db = new DAL.dbDataContext()) { cusVendor = db.CustomersAndVendors.Single(s => s.ID == id); isCustomer = cusVendor.IsCustomer; GetData(); } }
void LoadProduct(int id) { using (var db = new DAL.dbDataContext()) { product = db.Products.Single(x => x.ID == id); } this.Text = string.Format("بيانات صنف : {0}", product.Name); GetData(); }
public override void RefreshData() { var db = new DAL.dbDataContext(); var groups = db.ProductCategories; lookUpEdit1.Properties.DataSource = groups; treeList1.DataSource = groups; treeList1.ExpandAll(); base.RefreshData(); }
private string GetNewInvoiceCode() { string maxCode; using (var db = new DAL.dbDataContext()) { maxCode = db.InvoiceHeaders.Where(x => x.InvoiceType == (int)type).Select(x => x.Code).Max(); } return(GetNextNumberInString(maxCode)); }
private string GetNewBarCode() { string maxCode; using (var db = new DAL.dbDataContext()) { maxCode = db.ProductUnits.Select(x => x.Barcode).Max(); } return(GetNextNumberInString(maxCode)); }
private void TreeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { int id = 0; if (int.TryParse(e.Node.GetValue(nameof(category.ID)).ToString(), out id)) { var db = new DAL.dbDataContext(); category = db.ProductCategories.Single(x => x.ID == id); GetData(); } }
void GetData() { DAL.dbDataContext db = new DAL.dbDataContext(); DAL.CompanyInfo info = db.CompanyInfos.FirstOrDefault(); if (info == null) { return; } txt_name.Text = info.CompanyName; txt_address.Text = info.Address; txt_phone.Text = info.Phone; txt_mobile.Text = info.Mobile; }
public override void Save() { if (textEdit1.Text.Trim() == string.Empty) { textEdit1.ErrorText = "برجاء ادخال اسم الفرع"; return; } DAL.Account SalesAccount = new DAL.Account(); DAL.Account SalesReturnAccount = new DAL.Account(); DAL.Account InventoryAccount = new DAL.Account(); DAL.Account CostOfSoldGoodsAccont = new DAL.Account(); var db = new DAL.dbDataContext(); if (store.ID == 0) { db.Stores.InsertOnSubmit(store); db.Accounts.InsertOnSubmit(SalesAccount); db.Accounts.InsertOnSubmit(SalesReturnAccount); db.Accounts.InsertOnSubmit(InventoryAccount); db.Accounts.InsertOnSubmit(CostOfSoldGoodsAccont); store.DiscountAllowedAccountID = Session.Defaults.DiscountAllowedAccount; store.DiscountReveiedAccountID = Session.Defaults.DiscountReceivedAccount; } else { db.Stores.Attach(store); SalesAccount = db.Accounts.Single(x => x.ID == store.SalesAccountID); SalesReturnAccount = db.Accounts.Single(x => x.ID == store.SalesReturnAccountID); InventoryAccount = db.Accounts.Single(x => x.ID == store.InventoryAccountID); CostOfSoldGoodsAccont = db.Accounts.Single(x => x.ID == store.CostOfSoldGoodsAccountID); } SetData(); SalesAccount.Name = store.Name + "- مبيعات"; SalesReturnAccount.Name = store.Name + "- مردود مبيعات"; InventoryAccount.Name = store.Name + "- المخزون"; CostOfSoldGoodsAccont.Name = store.Name + "- تكلفه البضاعه المباعه"; db.SubmitChanges(); store.SalesAccountID = SalesAccount.ID; store.SalesReturnAccountID = SalesReturnAccount.ID; store.InventoryAccountID = InventoryAccount.ID; store.CostOfSoldGoodsAccountID = CostOfSoldGoodsAccont.ID; db.SubmitChanges(); base.Save(); }
private void btnSave_Click(object sender, EventArgs e) { if (txtName.Text.Trim() == string.Empty) { MessageBox.Show("الرجاء عدم ترك حقل الاسم فارغ"); return; } if (Cmb_stores.SelectedValue == null) { MessageBox.Show("الرجاء اختيار مخزن"); return; } if (Cmb_stores.SelectedValue == null) { MessageBox.Show("الرجاء اختيار وحدة رئيسية"); return; } if (item.id == 0) { db = new DAL.dbDataContext(); db.items.InsertOnSubmit(item); unit_relation.item = item; unit_relation.sup_unit = Convert.ToInt32(Cmb_unites.SelectedValue.ToString()); unit_relation.ratio = 1; db.unites_relations.InsertOnSubmit(unit_relation); SetData(); db.SubmitChanges(); foreach (DataGridViewRow row in dgv_subUnits.Rows) { //unit_relation = new DAL.unites_relation(); //unit_relation.item_id = item.id; //unit_relation.sup_unit = Convert.ToInt32(row.Cells["unit_id"].Value); //unit_relation.ratio = Convert.ToInt32(row.Cells["ratioN"].Value); //db.unites_relations.InsertOnSubmit(unit_relation); //db.SubmitChanges(); } } else { unit_relation = db.unites_relations.Where(i => i.item_id == item.id).Where(i => i.ratio == 1).First(); unit_relation.sup_unit = Convert.ToInt32(Cmb_unites.SelectedValue.ToString()); SetData(); db.SubmitChanges(); } MessageBox.Show("تم إضافة الصنف بنجاح"); refreshItems(); New(); }
private void Lkp_Category_ProcessNewValue(object sender, DevExpress.XtraEditors.Controls.ProcessNewValueEventArgs e) { if (e.DisplayValue is string st && st.Trim() != string.Empty) { var newObject = new DAL.ProductCategory() { Name = st, ParentID = 0, Number = "0" }; using (var db = new DAL.dbDataContext()) { db.ProductCategories.InsertOnSubmit(newObject); db.SubmitChanges(); } ((List <DAL.ProductCategory>)lkp_Category.Properties.DataSource).Add(newObject); e.Handled = true; } }
bool IsDataValidated() { if (textEdit1.Text.Trim() == string.Empty) { textEdit1.ErrorText = "هذا الحقل مطلوب"; return(false); } var db = new DAL.dbDataContext(); if (db.ProductCategories.Where(x => x.Name.Trim() == textEdit1.Text.Trim() && x.ID != category.ID).Count() > 0) { textEdit1.ErrorText = "هذا الاسم مسجل مسبقا"; return(false); } return(true); }
bool IsDataValidated() { if (txt_Name.Text.Trim() == string.Empty) { txt_Name.ErrorText = "هذا الحقل مطلوب"; return(false); } var db = new DAL.dbDataContext(); if (db.CustomersAndVendors.Where(x => x.Name.Trim() == txt_Name.Text.Trim() && x.IsCustomer == isCustomer && x.ID != cusVendor.ID).Count() > 0) { txt_Name.ErrorText = "هذا الاسم مسجل مسبقا"; return(false); } return(true); }
private void Items_form_Load(object sender, EventArgs e) { Cmb_stores.DataSource = db.stores; Cmb_stores.ValueMember = "id"; Cmb_stores.DisplayMember = "name"; Cmb_unites.DataSource = db.unites; Cmb_unites.ValueMember = "id"; Cmb_unites.DisplayMember = "name"; refreshItems(); if (dgvItems.Rows.Count > 0) { dgvItems.Rows[0].Selected = true; } db2 = new DAL.dbDataContext(); Cmb_subUnit.DataSource = db2.unites; Cmb_subUnit.ValueMember = "id"; Cmb_subUnit.DisplayMember = "name"; New(); }
private void RepoUOM_ProcessNewValue(object sender, DevExpress.XtraEditors.Controls.ProcessNewValueEventArgs e) { if (e.DisplayValue is string value && value.Trim() != string.Empty) { var NewObject = new DAL.UnitName() { Name = value.Trim() }; using (DAL.dbDataContext db = new DAL.dbDataContext()) { db.UnitNames.InsertOnSubmit(NewObject); db.SubmitChanges(); } ((List <DAL.UnitName>)repoUOM.DataSource).Add(NewObject); ((List <DAL.UnitName>)((LookUpEdit)sender).Properties.DataSource).Add(NewObject); e.Handled = true; } }
private void GridView1_CustomRowCellEditForEditing(object sender, CustomRowCellEditEventArgs e) { if (e.Column.FieldName == nameof(ins.UnitID)) { var ids = ((Collection <DAL.ProductUnit>)gridView1.DataSource).Select(x => x.UnitID).ToList(); RepositoryItemLookUpEdit repo = new RepositoryItemLookUpEdit(); using (var db = new DAL.dbDataContext()) { var currentId = (Int32?)e.CellValue; ids.Remove(currentId ?? 0); repo.DataSource = db.UnitNames.Where(x => ids.Contains(x.ID) == false).ToList(); repo.ValueMember = "ID"; repo.DisplayMember = "Name"; repo.PopulateColumns(); repo.Columns["ID"].Visible = false; repo.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard; repo.ProcessNewValue += RepoUOM_ProcessNewValue; e.RepositoryItem = repo; } } }
private void btnDelete_Click(object sender, EventArgs e) { int id = 0; if (dgvUsers.CurrentRow.Cells[0].Value != null) { id = Convert.ToInt32(dgvUsers.CurrentRow.Cells[0].Value.ToString()); user = db.users.Where(s => s.id == id).FirstOrDefault(); DialogResult dialog = MessageBox.Show("هل تريد بالفعل حذف هذا المستخدم", "تحذير", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { db.users.DeleteOnSubmit(user); db.SubmitChanges(); db = new DAL.dbDataContext(); dgvUsers.DataSource = db.users; dgvUsers.Columns["id"].Visible = false; dgvUsers.Columns["name"].HeaderText = "الاسم"; New(); btnDelete.Enabled = false; } } }
void Save() { if (txt_name.Text.Trim() == String.Empty) { txt_name.ErrorText = "برجاء ادخال اسم الشركة"; return; } DAL.dbDataContext db = new DAL.dbDataContext(); DAL.CompanyInfo info = db.CompanyInfos.FirstOrDefault(); if (info == null) { info = new DAL.CompanyInfo(); } info.CompanyName = txt_name.Text; info.Mobile = txt_mobile.Text; info.Phone = txt_phone.Text; info.Address = txt_address.Text; db.SubmitChanges(); XtraMessageBox.Show("تم الحفظ بنجاح"); }