private void StockGroupSearch_KeyUp(object sender, KeyEventArgs e) { List <stock_group_master> stockgroup = new List <stock_group_master>(); if (StockGroupNameSearch.Text != null && StockGroupNameSearch.Text != "") { using (invetoryEntities db = new invetoryEntities()) { if (db.stock_group_master.Where(x => x.name.ToLower().Contains(StockGroupNameSearch.Text)).ToList().Count > 0) { foreach (var item in db.stock_group_master.Where(x => x.name.ToLower().Contains(StockGroupNameSearch.Text)).ToList()) { stockgroup.Add(new stock_group_master { name = item.name.ToString(), id = item.id }); } stockGroupViewModel.pagingCollectionView = new PagingCollectionView(stockgroup, 100000); this.DataContext = stockGroupViewModel; } else { LoadGrid(); } } } else { LoadGrid(); } }
//private void Button_Click_Modify(object sender, RoutedEventArgs e) //{ // if (GodownName.Text != "" && GodownName.Text != "") // { // using (invetoryEntities db = new invetoryEntities()) // { // var GodownID = Convert.ToInt32(GodownId.Text); // if (db.godown_master.Where(x => x.id == GodownID).ToList().Count > 0) // { // var godown = db.godown_master.Where(x => x.id == GodownID).FirstOrDefault(); // godown.name = GodownName.Text; // godown.Address = Address.Text; // db.SaveChanges(); // MessageBox.Show("Godown updated successfully."); // Clear_Form(); // LoadGrid(); // } // else // { // MessageBox.Show("Something went wrong please try again."); // } // } // } // else // { // MessageBox.Show("Please fill compulsory data."); // } //} private void ProductSearch_KeyUp(object sender, KeyEventArgs e) { List <ProductGridViewModel> product = new List <ProductGridViewModel>(); using (invetoryEntities db = new invetoryEntities()) { var searchquery = from p in db.product_master join u in db.unit_master on p.unit_id equals u.id where (p.product.Contains(ProductNameSearch.Text) || ProductNameSearch.Text == "") && (p.mrp.ToString().Contains(MRPSearch.Text) || MRPSearch.Text == "") && (u.name.Contains(UnitSearch.Text) || UnitSearch.Text == "") select new { p.product, p.mrp, u.name, p.id }; if (searchquery.ToList().Count > 0) { foreach (var item in searchquery) { product.Add(new ProductGridViewModel { product = item.product.ToString(), mrp = item.mrp, id = item.id, unit = item.name }); } pagingCollectionView = new PagingCollectionView(product, 100000); this.DataContext = pagingCollectionView; } else { LoadGrid(); } } }
private void Button_Click_Modify(object sender, RoutedEventArgs e) { if (UnitName.Text != "" && ShortCode.Text != "") { using (invetoryEntities db = new invetoryEntities()) { var UnitID = Convert.ToInt32(UnitId.Text); if (db.unit_master.Where(x => x.id == UnitID).ToList().Count > 0) { var unit = db.unit_master.Where(x => x.id == UnitID).FirstOrDefault(); unit.name = UnitName.Text; unit.code = ShortCode.Text; db.SaveChanges(); MessageBox.Show("Unit updated successfully."); Clear_Form(); } else { MessageBox.Show("Something went wrong please try again."); } } } else { MessageBox.Show("Please fill compulsory data."); } }
private void Delete() { MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure?", "Delete Confirmation", MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) // error is here { if (datagrid.SelectedIndex >= 0) { company_master company = datagrid.SelectedItem as company_master; using (invetoryEntities db = new invetoryEntities()) { if (db.company_master.Where(x => x.id == company.id).ToList().Count > 0) { db.company_master.Remove(db.company_master.Find(company.id)); db.SaveChanges(); MessageBox.Show("Company deleted successfully."); LoadGrid(); } else { MessageBox.Show("Something went wrong please try again."); } } } } else { MessageBox.Show("Delete operation Terminated"); } }
private void Button_Click_Modify(object sender, RoutedEventArgs e) { if (GodownName.Text != "" && GodownName.Text != "") { using (invetoryEntities db = new invetoryEntities()) { var GodownID = Convert.ToInt32(GodownId.Text); if (db.godown_master.Where(x => x.id == GodownID).ToList().Count > 0) { var godown = db.godown_master.Where(x => x.id == GodownID).FirstOrDefault(); godown.name = GodownName.Text; godown.Address = Address.Text; db.SaveChanges(); MessageBox.Show("Godown updated successfully."); Clear_Form(); } else { MessageBox.Show("Something went wrong please try again."); } } } else { MessageBox.Show("Please fill compulsory data."); } }
private void CompanyNameSearch_KeyUp(object sender, KeyEventArgs e) { List <company_master> company = new List <company_master>(); if (CompanyNameSearch.Text != null && CompanyNameSearch.Text != "") { using (invetoryEntities db = new invetoryEntities()) { if (db.company_master.Where(x => x.name.ToLower().Contains(CompanyNameSearch.Text)).ToList().Count > 0) { foreach (var item in db.company_master.Where(x => x.name.ToLower().Contains(CompanyNameSearch.Text)).ToList()) { company.Add(new company_master { name = item.name.ToString(), finanacial_year = item.finanacial_year, id = item.id }); } this.DataContext = new PagingCollectionView(company, 10000); } else { LoadGrid(); } } } else { LoadGrid(); } }
private void Button_Click_Delete(object sender, RoutedEventArgs e) { MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure?", "Delete Confirmation", MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) // error is here { if (datagrid.SelectedIndex >= 0) { under_master under = datagrid.SelectedItem as under_master; using (invetoryEntities db = new invetoryEntities()) { if (db.under_master.Where(x => x.id == under.id).ToList().Count > 0) { db.under_master.Remove(db.under_master.Find(under.id)); db.SaveChanges(); MessageBox.Show("Under deleted successfully."); LoadGrid(); } else { MessageBox.Show("Something went wrong please try again."); } } } } else { MessageBox.Show("Delete operation Terminated"); } }
private void Button_Click_Save(object sender, RoutedEventArgs e) { if (ProductName.Text != "" && TransactionType.SelectedValue.ToString() != "" && Price.Text != "" && Quantity.Text != "") { using (invetoryEntities db = new invetoryEntities()) { db.stock_detail.Add(new stock_detail { product_id = Convert.ToInt32(ProductName.SelectedValue), transaction_type = Convert.ToInt32(TransactionType.SelectedValue), quantity = Convert.ToInt32(Quantity.Text), price = Convert.ToDecimal(Price.Text), created_date = DateTime.Now, company_id = 1 }); db.SaveChanges(); MessageBox.Show("Stock Added successfully."); Clear_Form(); } } else { MessageBox.Show("Please fill compulsory data."); } }
private void UnderSearch_KeyUp(object sender, KeyEventArgs e) { List <under_master> under = new List <under_master>(); if (UnderNameSearch.Text != null && UnderNameSearch.Text != "") { using (invetoryEntities db = new invetoryEntities()) { if (db.under_master.Where(x => x.name.ToLower().Contains(UnderNameSearch.Text)).ToList().Count > 0) { foreach (var item in db.under_master.Where(x => x.name.ToLower().Contains(UnderNameSearch.Text)).ToList()) { under.Add(new under_master { name = item.name.ToString(), id = item.id }); } underViewModel.pagingCollectionView = new PagingCollectionView(under, 100000); this.DataContext = underViewModel; } else { LoadGrid(); } } } else { LoadGrid(); } }
private void Button_Click_Modify(object sender, RoutedEventArgs e) { if (StockGroupName.Text != "") { using (invetoryEntities db = new invetoryEntities()) { var StockGroupID = Convert.ToInt32(StockGroupId.Text); if (db.stock_group_master.Where(x => x.id == StockGroupID).ToList().Count > 0) { var stockgroup = db.stock_group_master.Where(x => x.id == StockGroupID).FirstOrDefault(); stockgroup.name = StockGroupName.Text; db.SaveChanges(); MessageBox.Show("Stock Group updated successfully."); Clear_Form(); } else { MessageBox.Show("Something went wrong please try again."); } } } else { MessageBox.Show("Please fill compulsory data."); } }
private void Button_Click_Login(object sender, RoutedEventArgs e) { if (UserName.Text != "" && Password.Text != "") { using (invetoryEntities db = new invetoryEntities()) { if (db.user_master.Where(x => x.username == UserName.Text && x.password == Password.Text).ToList().Count > 0) { foreach (Window window in Application.Current.Windows) { if (window.GetType() == typeof(MainWindow)) { (window as MainWindow).InvetoryInfo.IsEnabled = true; (window as MainWindow).AccountInfo.IsEnabled = true; (window as MainWindow).TransactionInfo.IsEnabled = true; (window as MainWindow).Display.IsEnabled = true; this.Close(); (window as MainWindow).Main.Content = null; } } } else { MessageBox.Show("Details are wrong please try again"); } } } else { MessageBox.Show("Please fill compulsory fields"); } }
private ProductViewModel GetProductById(int id) { ProductViewModel data = new ProductViewModel(); try { using (invetoryEntities db = new invetoryEntities()) { var query = (from pro in db.product_master join unit in db.unit_master on pro.unit_id equals unit.id where pro.id == id select new { mrp = pro.mrp, unit_name = unit.code }).FirstOrDefault(); data.MRP = query.mrp.ToString(); data.Unit = query.unit_name; } } catch (Exception) { } return(data); }
private void SaveProduct() { if (ProductName.Text != "") { using (invetoryEntities db = new invetoryEntities()) { product_master product_Master = new product_master { product = ProductName.Text, category_id = 1, //item_group_id = Convert.ToInt32(ItemGroup.SelectedValue), unit_id = Convert.ToInt32(Unit.SelectedValue), alternat_unit_id = Convert.ToInt32(AlternetUnit.SelectedValue), mrp = Convert.ToDecimal(MRP.Text), rate_on = 1, tax_type = 1, sale_rate_on = 1, rate_persantage = 1, discount_consumer = 1, discount_other = 1, discount_on_qty = 1, brokerage = 1, min_qty = 1, order_qty = 1, status = 1, created_on = DateTime.Now, }; db.product_master.Add(product_Master); db.SaveChanges(); product_expenses_master product_Expenses_Master = new product_expenses_master { adhat = (Adhat.Text == ""?0:Convert.ToDecimal(Adhat.Text)), adhat_unit_id = Convert.ToInt32(AdhatPer.SelectedValue), taulai = (Taulai.Text == "" ? 0 : Convert.ToDecimal(Taulai.Text)), taulai_unit_id = Convert.ToInt32(TaulaiPer.SelectedValue), majoori = (Majoori.Text == "" ? 0 : Convert.ToDecimal(Majoori.Text)), majoori_unit_id = Convert.ToInt32(MajooriPer.SelectedValue), packing = (Packing.Text == "" ? 0 : Convert.ToDecimal(Packing.Text)), packing_unit_id = Convert.ToInt32(PackingPer.SelectedValue), mandi_sulk = (MundiSulk.Text == "" ? 0 : Convert.ToDecimal(MundiSulk.Text)), mandi_sulk_unit_id = Convert.ToInt32(MundiSulkPer.SelectedValue), vikash_sesh = (VikashSesh.Text == "" ? 0 : Convert.ToDecimal(VikashSesh.Text)), vikash_sesh_unit_id = Convert.ToInt32(VikashSeshPer.SelectedValue), packing_less = (PackingLess.Text == "" ? 0 : Convert.ToDecimal(VikashSesh.Text)), packing_less_unit_id = Convert.ToInt32(PackingLessPer.SelectedValue), product_id = product_Master.id, created_on = DateTime.Now, status = 1 }; db.product_expenses_master.Add(product_Expenses_Master); db.SaveChanges(); MessageBox.Show("Product save successfully."); //Clear_Form(); } } else { MessageBox.Show("Please fill compulsory data."); } }
private void Button_Click_Save(object sender, RoutedEventArgs e) { using (invetoryEntities db = new invetoryEntities()) { db.company_master.Add(new company_master { name = Name.Text, address = Address.Text, finanacial_year = Financialyear.SelectedDate.Value, pin_no = PINNo.Text }); db.SaveChanges(); MessageBox.Show("Company save successfully."); Creal_Form(); } }
private void Save() { try { if (LedgerName.Text != "") { using (invetoryEntities db = new invetoryEntities()) { ledger_master ledger_Master = new ledger_master { name = LedgerName.Text, under_id = Convert.ToInt32(UnderName.SelectedValue), billing_style = BillingStyle.Text, opening_balance = Convert.ToDecimal(OpeningBalance.Text), credit_debit_type = Convert.ToInt32(CreditDebitType.SelectedValue), print_name = PrintName.Text, owner_name = OwnerName.Text, address = Address.Text, state = 1, pin_code = PinCode.Text, mobile = Mobile.Text, aadhar_no = AadharNo.Text, email = EmailID.Text, area = Area.Text, agent = 1, interest = Convert.ToBoolean(Interest.SelectedValue), credit_priod = 1, less_priod = 1, interest_rate = 1, description = Description.Text, company_id = 1, created_on = DateTime.Now, }; db.ledger_master.Add(ledger_Master); db.SaveChanges(); MessageBox.Show("Ledger saved successfully."); } } else { MessageBox.Show("Please fill compulsory data."); } } catch (Exception ex) { } }
private void Button_Click_Save(object sender, RoutedEventArgs e) { if (StockGroupName.Text != "") { using (invetoryEntities db = new invetoryEntities()) { db.stock_group_master.Add(new stock_group_master { name = StockGroupName.Text }); db.SaveChanges(); MessageBox.Show("Stock Group save successfully."); Clear_Form(); } } else { MessageBox.Show("Please fill compulsory data."); } }
public List <company_master> GetCompanies() { List <company_master> companies = new List <company_master>(); using (invetoryEntities db = new invetoryEntities()) { if (db.company_master.ToList().Count > 0) { foreach (var item in db.company_master.ToList()) { companies.Add(new company_master { name = item.name.ToString(), finanacial_year = item.finanacial_year }); } } } return(companies); }
public List <under_master> GetUnder() { List <under_master> stockgroups = new List <under_master>(); using (invetoryEntities db = new invetoryEntities()) { if (db.under_master.ToList().Count > 0) { foreach (var item in db.under_master.ToList()) { stockgroups.Add(new under_master { name = item.name.ToString(), id = item.id }); } } } return(stockgroups); }
private void Button_Click_Save(object sender, RoutedEventArgs e) { if (UnitName.Text != "" && ShortCode.Text != "") { using (invetoryEntities db = new invetoryEntities()) { db.unit_master.Add(new unit_master { name = UnitName.Text, code = ShortCode.Text }); db.SaveChanges(); MessageBox.Show("Unit save successfully."); Clear_Form(); } } else { MessageBox.Show("Please fill compulsory data."); } }
public List <godown_master> GetGodown() { List <godown_master> godown = new List <godown_master>(); using (invetoryEntities db = new invetoryEntities()) { if (db.godown_master.ToList().Count > 0) { foreach (var item in db.godown_master.ToList()) { godown.Add(new godown_master { name = item.name.ToString(), Address = item.Address, id = item.id }); } } } return(godown); }
public List <unit_master> Getunities() { List <unit_master> unities = new List <unit_master>(); using (invetoryEntities db = new invetoryEntities()) { if (db.unit_master.ToList().Count > 0) { foreach (var item in db.unit_master.ToList()) { unities.Add(new unit_master { name = item.name.ToString(), code = item.code.ToString(), id = item.id }); } } } return(unities); }
private void Button_Click_Save(object sender, RoutedEventArgs e) { if (GodownName.Text != "" && GodownName.Text != "") { using (invetoryEntities db = new invetoryEntities()) { db.godown_master.Add(new godown_master { name = GodownName.Text, Address = Address.Text }); db.SaveChanges(); MessageBox.Show("Godown save successfully."); Clear_Form(); } } else { MessageBox.Show("Please fill compulsory data."); } }
public List <ProductGridViewModel> GetProduct() { List <ProductGridViewModel> product = new List <ProductGridViewModel>(); using (invetoryEntities db = new invetoryEntities()) { if (db.product_master.ToList().Count > 0) { foreach (var item in db.product_master.ToList()) { product.Add(new ProductGridViewModel { product = item.product.ToString(), unit = db.unit_master.Where(x => x.id == item.unit_id).FirstOrDefault().name, id = item.id, mrp = item.mrp }); } } } return(product); }
public List <ProductCollection> GetProductCollection() { List <ProductCollection> products = new List <ProductCollection>(); using (invetoryEntities db = new invetoryEntities()) { if (db.product_master.ToList().Count > 0) { foreach (var item in db.product_master.ToList()) { products.Add(new ProductCollection { ProductId = item.id, ProductName = item.product }); } return(products); } else { return(products); } } }
public static List <UnderViewModel> GetUnderCollection() { List <UnderViewModel> unders = new List <UnderViewModel>(); using (invetoryEntities db = new invetoryEntities()) { if (db.under_master.ToList().Count > 0) { foreach (var item in db.under_master.ToList()) { unders.Add(new UnderViewModel { UnderId = item.id.ToString(), UnderName = item.name }); } return(unders); } else { return(unders); } } }
public List <UnitCollection> GetUnitCollection() { List <UnitCollection> units = new List <UnitCollection>(); using (invetoryEntities db = new invetoryEntities()) { if (db.unit_master.ToList().Count > 0) { foreach (var item in db.unit_master.ToList()) { units.Add(new UnitCollection { UnitId = item.id.ToString(), UnitName = item.name }); } return(units); } else { return(units); } } }
public static List <ItemGroupCollection> GetItemGroupCollection() { List <ItemGroupCollection> itemgroups = new List <ItemGroupCollection>(); using (invetoryEntities db = new invetoryEntities()) { if (db.stock_group_master.ToList().Count > 0) { foreach (var item in db.stock_group_master.ToList()) { itemgroups.Add(new ItemGroupCollection { ItemGroupId = item.id.ToString(), ItemGroupName = item.name }); } return(itemgroups); } else { return(itemgroups); } } }
public static List <PartyViewModel> GetPartyCollection() { List <PartyViewModel> parties = new List <PartyViewModel>(); using (invetoryEntities db = new invetoryEntities()) { if (db.ledger_master.ToList().Count > 0) { foreach (var item in db.ledger_master.ToList()) { parties.Add(new PartyViewModel { party_id = item.id, party_name = item.name }); } return(parties); } else { return(parties); } } }
private void Save() { if (SerialNo.Text != null && SerialNo.Text != "") { using (invetoryEntities db = new invetoryEntities()) { purchase_master purchase_master = new purchase_master { serial_no = Convert.ToInt32(SerialNo.Text), book_no = Convert.ToInt32(BookNo.Text), purchase_date = PurchaseInvoiceDate.SelectedDate, party_name_id = Convert.ToInt32(PartyName.SelectedValue), supplier_invoice_no = Convert.ToInt32(SupplierInvoiceNo.Text), purchase_date1 = Date.SelectedDate, gross_amount = Convert.ToDecimal(GrossAmount.Text), paking_amount = Convert.ToDecimal(Paking.Text), dis_amount = Convert.ToDecimal(Dis.Text), other_charges = Convert.ToDecimal(OtherCharges.Text), round_off = Convert.ToDecimal(RoundOff.Text), net_amount = Convert.ToDecimal(NetAmount.Text), status = 1, created_by = 1, company_id = 1, created_on = DateTime.Now, }; db.purchase_master.Add(purchase_master); db.SaveChanges(); db.purchase_expenses.Add(new purchase_expenses { purchase_id = purchase_master.purchase_id, adhat = Convert.ToDecimal(Adhat.Text), taulai = Convert.ToDecimal(Taulai.Text), majoori = Convert.ToDecimal(Majdoori.Text), packing = Convert.ToDecimal(Packing.Text), mandi_sulk = Convert.ToDecimal(MandiSulk.Text), vikash_sesh = Convert.ToDecimal(VikashSesh.Text), other = Convert.ToDecimal(Other.Text), status = 1, company_id = 1, created_by = 1, created_on = DateTime.Now }); db.SaveChanges(); List <SalesInvoiceCollectionViewModel> salesInvoiceCollectionViewModels = (List <SalesInvoiceCollectionViewModel>)PurchaseInvoiceDataGrid.ItemsSource; for (int i = 0; i < salesInvoiceCollectionViewModels.Count - 1; i++) { purchase_details purchase_details = new purchase_details { purchase_id = purchase_master.purchase_id, product_id = Convert.ToInt32(salesInvoiceCollectionViewModels[i].name), sr_no = Convert.ToInt32(salesInvoiceCollectionViewModels[i].sr), alternate_qty = salesInvoiceCollectionViewModels[i].qty.ToString(), gross_weight = Convert.ToDecimal(salesInvoiceCollectionViewModels[i].grossnet), less = Convert.ToDecimal(salesInvoiceCollectionViewModels[i].less), net_weight = salesInvoiceCollectionViewModels[i].netweight.ToString(), rate = Convert.ToDecimal(salesInvoiceCollectionViewModels[i].rate), per = salesInvoiceCollectionViewModels[i].per, amount = Convert.ToDecimal(salesInvoiceCollectionViewModels[i].amount), created_by = 1, company_id = 1, created_on = DateTime.Now, status = 1 }; db.purchase_details.Add(purchase_details); db.SaveChanges(); } MessageBox.Show("Purchase save successfully."); //Clear_Form(); } } else { MessageBox.Show("Please fill compulsory data."); } }
//private void Button_Click_Modify(object sender, RoutedEventArgs e) //{ // if (GodownName.Text != "" && GodownName.Text != "") // { // using (invetoryEntities db = new invetoryEntities()) // { // var GodownID = Convert.ToInt32(GodownId.Text); // if (db.godown_master.Where(x => x.id == GodownID).ToList().Count > 0) // { // var godown = db.godown_master.Where(x => x.id == GodownID).FirstOrDefault(); // godown.name = GodownName.Text; // godown.Address = Address.Text; // db.SaveChanges(); // MessageBox.Show("Godown updated successfully."); // Clear_Form(); // LoadGrid(); // } // else // { // MessageBox.Show("Something went wrong please try again."); // } // } // } // else // { // MessageBox.Show("Please fill compulsory data."); // } //} private void GodownSearch_KeyUp(object sender, KeyEventArgs e) { List <godown_master> godowns = new List <godown_master>(); if (GodownNameSearch.Text != null && GodownNameSearch.Text != "") { using (invetoryEntities db = new invetoryEntities()) { if (db.godown_master.Where(x => x.name.ToLower().Contains(GodownNameSearch.Text)).ToList().Count > 0) { foreach (var item in db.godown_master.Where(x => x.name.ToLower().Contains(GodownNameSearch.Text)).ToList()) { godowns.Add(new godown_master { name = item.name.ToString(), Address = item.Address.ToString(), id = item.id }); } godownViewModel.pagingCollectionView = new PagingCollectionView(godowns, 100000); this.DataContext = godownViewModel; } else { LoadGrid(); } } } else if (AddressSearch.Text != null && AddressSearch.Text != "") { using (invetoryEntities db = new invetoryEntities()) { if (db.godown_master.Where(x => x.Address.ToLower().Contains(AddressSearch.Text)).ToList().Count > 0) { foreach (var item in db.godown_master.Where(x => x.Address.ToLower().Contains(AddressSearch.Text)).ToList()) { godowns.Add(new godown_master { name = item.name.ToString(), Address = item.Address.ToString(), id = item.id }); } godownViewModel.pagingCollectionView = new PagingCollectionView(godowns, 100000); this.DataContext = godownViewModel; } else { LoadGrid(); } } } else if (GodownNameSearch.Text != null && GodownNameSearch.Text != "" && AddressSearch.Text != null && AddressSearch.Text != "") { using (invetoryEntities db = new invetoryEntities()) { if (db.godown_master.Where(x => x.Address.ToLower().Contains(AddressSearch.Text) || x.name.ToLower().Contains(GodownNameSearch.Text)).ToList().Count > 0) { foreach (var item in db.godown_master.Where(x => x.Address.ToLower().Contains(AddressSearch.Text) || x.name.ToLower().Contains(GodownNameSearch.Text)).ToList()) { godowns.Add(new godown_master { name = item.name.ToString(), Address = item.Address.ToString(), id = item.id }); } godownViewModel.pagingCollectionView = new PagingCollectionView(godowns, 100000); this.DataContext = godownViewModel; } else { LoadGrid(); } } } else { LoadGrid(); } }