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 static ProductViewClass GetProduct(int ID) { ProductViewClass Obj; using (SalesDataContext db = new SalesDataContext()) { IEnumerable <ProductViewClass> data = from pr in Products join cat in db.product_categories on pr.category_id equals cat.id where pr.id == ID select new ProductViewClass { id = pr.id, code = pr.code, name = pr.Name, category = cat.name, type = pr.type, details = pr.details, status = pr.status, Units = (from u in db.products_units where u.productid == pr.id join un in db.units on u.unitid equals un.id select new ProductViewClass.ProductUOMView { unitid = u.unitid, UnitName = un.name, factor = u.factor, sellprice = u.sellprice, buyprice = u.buyprice, barcode = u.barcode, }).ToList() }; Obj = data.First(); }; return(Obj); }
public override void GetData() { Txt_Code.EditValue = Invoice.code; Dt_Date.EditValue = Invoice.date; Lkp_PartType.EditValue = Invoice.part_type; GLkp_PartName.EditValue = Invoice.part_id; Chk_PostedTostore.Checked = Invoice.posted_tostore; Lkp_Branch.EditValue = Invoice.branch; Dt_PostedDate.EditValue = Invoice.post_date; Mem_Notes.EditValue = Invoice.notes; Dt_DeliveryDate.EditValue = Invoice.delivery_date; Mem_ShippmentAddress.EditValue = Invoice.shippment_address; Lkp_Treasurys.EditValue = Invoice.treasurys; Sp_Paid.EditValue = Invoice.paid; Sp_Remaing.EditValue = Invoice.remaing; Sp_Total.EditValue = Invoice.total; Sp_TaxValue.EditValue = Invoice.tax_value; Sp_TaxRatio.EditValue = Invoice.tax; Sp_Expences.EditValue = Invoice.expences; Sp_DiscValue.EditValue = Invoice.discount_value; Sp_DiscRatio.EditValue = Invoice.discount_ratio; Sp_Net.EditValue = Invoice.net; GenralDB = new SalesDataContext(); Grid_Details.DataSource = GenralDB.invoices_details.Where(x => x.invoiceid == Invoice.id); base.GetData(); }
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") }); }
bool ValidateData() { if (Txt_Name.Text.Trim() == string.Empty) { Txt_Name.ErrorText = ErrorText; return(false); } if (Txt_Type.EditValue is int == false) { Txt_Type.ErrorText = ErrorText; return(false); } if (Convert.ToInt32(Txt_Category.EditValue) <= 0) { Txt_Category.ErrorText = ErrorText; return(false); } using (SalesDataContext db = new SalesDataContext()) { if (db.products.Where(x => x.id != Product.id && x.Name.Trim() == Txt_Name.Text.Trim() && x.id != Product.id).Count() > 0) { Txt_Name.ErrorText = "هذا الاسم موجود مسبقا في قاعدة البيانات"; return(false); } if (db.products.Where(x => x.id != Product.id && x.code.Trim() == Txt_Code.Text.Trim() && x.id != Product.id).Count() > 0) { Txt_Code.ErrorText = "هذا الكود موجود مسبقا في قاعدة البيانات"; return(false); } } return(true); }
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 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 Frm_Stores(int id) { InitializeComponent(); var db = new SalesDataContext(); Store = db.stores.Where(S => S.id == id).First(); GetData(); }
void LoadTreasury(int id) { using (SalesDataContext db = new SalesDataContext()) { Treasury = db.treasurys.Single(x => x.id == id); GetData(); } }
void LoadProduct(int id) { using (SalesDataContext db = new SalesDataContext()) { Product = db.products.Single(Pr => Pr.id == id); } GetData(); }
public override void RefreshData() { using (SalesDataContext db = new SalesDataContext()) { Grid_CustSup.DataSource = (IsCustomer)? Session.Customers.ToList():Session.Suppliers.ToList(); } base.RefreshData(); }
/// <summary> /// Usa la clase en Sales.Datails.dbml /// Usa LinQ /// </summary> public static IEnumerable <SalesOrderHeader> BuscarVentasByParams(int pCustomerID) { SalesDataContext dc = new SalesDataContext(); IEnumerable <SalesOrderHeader> detalles = from sales in dc.SalesOrderHeaders where sales.CustomerID == pCustomerID select sales; return(detalles); }
void LoadObject(int id) { using (SalesDataContext db = new SalesDataContext()) { Cust_Supp = db.customers_suppliers.Single(x => x.id == id); IsCustomer = Convert.ToBoolean(Cust_Supp.Iscustomer); GetData(); } }
public override void RefreshData() { var db = new SalesDataContext(); var groups = db.product_categories; LUp_Maingrp.Properties.DataSource = groups; T_ListCategory.DataSource = groups; T_ListCategory.ExpandAll(); base.RefreshData(); }
string GetNewBarCode() { string maxCode; using (var db = new SalesDataContext()) { maxCode = db.products_units.Select(x => x.barcode).Max(); } return(Master.GetNextNumberInString(maxCode)); }
string GetNewInvoiceCode() { string maxCode; using (var db = new SalesDataContext()) { maxCode = db.invoices_header.Where(x => x.invoice_type == (int)Type).Select(x => x.code).Max(); } return(Master.GetNextNumberInString(maxCode)); }
private void T_ListCategory_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { int id = 0; if (int.TryParse(e.Node.GetValue(nameof(categoy.id)).ToString(), out id)) { var db = new SalesDataContext(); categoy = db.product_categories.Single(x => x.id == id); GetData(); } }
public override void RefreshData() { using (SalesDataContext db = new SalesDataContext()) { Txt_Category.Properties.DataSource = db.product_categories.ToList() .Where(x => db.product_categories.Where(w => w.parent_id == x.id).Count() == 0).ToList(); upEdit.DataSource = db.units.ToList(); } base.RefreshData(); }
private static void GetCustomers() { using (var context = new SalesDataContext()) { var customers = context.Customers.ToList(); IQueryable <Customer> iquery = context.Customers; //.Where(c => c.FirstName == ""); IEnumerable <Customer> ienum = context.Customers; //.Where(c => c.FirstName == ""); foreach (var c in customers) { Console.WriteLine(c.FirstName); } } }
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; } }
bool IsEmpty() { if (Txt_Name.Text.Trim() == string.Empty) { Txt_Name.ErrorText = "هذا الحقل لايمكن ان يكون فارغا"; return(false); } var db = new SalesDataContext(); if (db.product_categories.Where(x => x.name.Trim() == Txt_Name.Text.Trim() && x.id != categoy.id).Count() > 0) { Txt_Name.ErrorText = "هذا الاسم موجود مسبقا في قاعدة البيانات"; return(false); } return(true); }
bool IsEmpty() { if (Txt_Name.Text.Trim() == string.Empty) { Txt_Name.ErrorText = "هذا الحقل لايمكن ان يكون فارغا"; return(false); } var db = new SalesDataContext(); if (db.customers_suppliers.Where(x => x.name.Trim() == Txt_Name.Text.Trim() && x.Iscustomer == IsCustomer && x.id != Cust_Supp.id).Count() > 0) { Txt_Name.ErrorText = "هذا الاسم موجود مسبقا في قاعدة البيانات"; return(false); } return(true); }
/// <summary> /// Usa la clase en Sales.Datails.dbml /// Usa LinQ /// </summary> public static List <DetailsView> BuscarDetallesToList(int pCustomerID) { SalesDataContext dc = new SalesDataContext(); var detallesView = from sales in dc.SalesOrderDetails where sales.SalesOrderHeader.CustomerID == pCustomerID select(new DetailsView { SalesOrderID = sales.SalesOrderID, ProductID = sales.ProductID, CarrierTrackingNumber = sales.CarrierTrackingNumber, OrderDate = sales.SalesOrderHeader.OrderDate }); return(detallesView.ToList <DetailsView>()); }
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 RefreshData() { using (SalesDataContext db = new SalesDataContext()) { Grid_Treasury.DataSource = db.treasurys.ToList();//GetNewBindingList(); } dgv.OptionsView.ShowIndicator = false; dgv.Columns[nameof(treasurys.id)].Visible = false; dgv.Columns[nameof(treasurys.name)].Caption = "اسم الخزنة"; dgv.Columns[nameof(treasurys.account_id)].Caption = "رقم الحساب"; dgv.OptionsBehavior.Editable = false; // Make the grid read-only. dgv.OptionsSelection.EnableAppearanceFocusedCell = false; // Prevent the focused cell from being highlighted. dgv.FocusRectStyle = DrawFocusRectStyle.RowFocus; // Draw a dotted focus rectangle around the entire row. dgv.CustomDrawColumnHeader += Dgv_CustomDrawColumnHeader; dgv.RowCellStyle += Dgv_RowCellStyle; base.RefreshData(); }
/// <summary> /// Usa la clase en Sales.Datails.dbml /// Usa LinQ /// </summary> public static IEnumerable <DetailsView> BuscarDetallesIEnumerableTodos(out int count) { SalesDataContext dc = new SalesDataContext(); IEnumerable <DetailsView> detallesView = from sales in dc.SalesOrderDetails select(new DetailsView { SalesOrderID = sales.SalesOrderID, ProductID = sales.ProductID, CarrierTrackingNumber = sales.CarrierTrackingNumber, OrderDate = sales.SalesOrderHeader.OrderDate }); count = detallesView.Count <DetailsView>(); return(detallesView); }
private void Frm_StoresList_Load(object sender, EventArgs e) { using (SalesDataContext db = new SalesDataContext()) { Grd_Stores.DataSource = db.stores.GetNewBindingList(); } using (GridView dgv = Grd_Stores.MainView as GridView) { dgv.OptionsView.ShowIndicator = false; dgv.OptionsView.ShowColumnHeaders = false; dgv.Columns[0].Visible = false; dgv.Columns[1].Caption = "الفروع والمخازن"; dgv.OptionsBehavior.Editable = false; // Make the grid read-only. dgv.OptionsSelection.EnableAppearanceFocusedCell = false; // Prevent the focused cell from being highlighted. dgv.FocusRectStyle = DrawFocusRectStyle.RowFocus; // Draw a dotted focus rectangle around the entire row. dgv.RowCellStyle += Dgv_RowCellStyle; dgv.CustomDrawColumnHeader += Dgv_CustomDrawColumnHeader; } Grd_Stores.DoubleClick += Grd_Stores_DoubleClick; }
private void Dgv_CustomRowCellEditForEditing(object sender, CustomRowCellEditEventArgs e) { if (e.Column.FieldName == nameof(ins.unitid)) { var ids = ((Collection <products_units>)dgv.DataSource).Select(x => x.unitid).ToList(); RepositoryItemLookUpEdit repo = new RepositoryItemLookUpEdit(); using (SalesDataContext db = new SalesDataContext()) { var CurrentID = (Int32?)e.CellValue; ids.Remove(CurrentID ?? 0); repo.DataSource = db.units.Where(x => ids.Contains(x.id) == false).ToList(); repo.ValueMember = nameof(units.id); repo.DisplayMember = nameof(units.name); repo.PopulateColumns(); repo.Columns[nameof(units.id)].Visible = false; repo.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard; repo.ProcessNewValue += UpEdit_ProcessNewValue; e.RepositoryItem = repo; } } }
public static void SeedData(SalesDataContext context) { System.Console.WriteLine("Applying Migrations..."); context.Database.Migrate(); if (!context.Articles.Any()) { System.Console.WriteLine("Adding data - seeding"); context.Articles.AddRange( new Article() { ArticleNumber = "articleNumber1", SalesPrice = 20.5, DateOfSale = new DateTime(2021, 1, 1) }, new Article() { ArticleNumber = "articleNumber2", SalesPrice = 30.5, DateOfSale = new DateTime(2020, 1, 10) }, new Article() { ArticleNumber = "articleNumber3", SalesPrice = 10.5, DateOfSale = new DateTime(2021, 1, 1) }, new Article() { ArticleNumber = "articleNumber4", SalesPrice = 50.5, DateOfSale = new DateTime(2020, 12, 25) }, new Article() { ArticleNumber = "articleNumber5", SalesPrice = 15.5, DateOfSale = new DateTime(2021, 1, 1) } ); context.SaveChanges(); } else { System.Console.WriteLine("Already have data - not seeding"); } }