public PurchaseController() { db = new HCSMLEntities1(); }
private void CrystalReportViewer1_Loaded(object sender, RoutedEventArgs e) { ReportDocument report = new ReportDocument(); if (m_isurduvisible) { report.Load("../../Reports/SaleReceipt_u.rpt"); } if (!m_isurduvisible) { report.Load("../../Reports/SaleReceipt_e.rpt"); } ArrayList reportdata = new ArrayList(); reportdata.Add(productSold); using(var db = new HCSMLEntities1()) { try { report.SetDataSource(from c in db.saleproducts where c.seqid == productSold.seqid select c); } catch (NotSupportedException ex) {} catch (Exception ex) {} } crystalReportsViewer1.ViewerCore.ReportSource = report; report.Dispose(); }
private void CrystalReportViewer1_Loaded(object sender, RoutedEventArgs e) { ReportDocument report = new ReportDocument(); if (!m_isurduvisible) { report.Load("../../Reports/ProdcutPurchase.rpt"); } if (m_isurduvisible) { report.Load("../../Reports/ProductPurchase_u.rpt"); } ArrayList reportdata = new ArrayList(); reportdata.Add(ProductPurchased); //report.SetDataSource(reportdata); using (var db = new HCSMLEntities1()) { report.SetDataSource(from c in db.purchaseproducts where c.seqid == ProductPurchased.seqid select c); } CrystalReportsViewerSeller1.ViewerCore.ReportSource = report; //ReportDocument report = new ReportDocument(); //report.Load("../../Reports/PurchaserReport.rpt"); //ArrayList reportdata = new ArrayList(); //reportdata.Add(ProductPurchased); //report.SetDataSource(reportdata); //using (var db = new HCSMLEntities()) //{ // report.SetDataSource(from c in db.purchaseproducts where c.seqid == 6 select c); //} //crystalReportsViewer1.ViewerCore.ReportSource = report; }
//private void btnPayAmount_Click(object sender, RoutedEventArgs e) //{ // if (!string.IsNullOrEmpty(tbAmountPaid.Text)) // { // decimal amountPaid = Convert.ToDecimal(tbAmountPaid.Text); // PurchaseProduct = new purchaseproduct(); // PurchaseProduct.sellerid = sellerid; // PurchaseProduct.seller_cde = sellertype; // PurchaseProduct.amoutpaid = amountPaid; // if (amountPaid > totalPayable) // { // PurchaseProduct.totalpayable = 0; // PurchaseProduct.totalreceivable = (int) (amountPaid - totalPayable); // } // else // { // PurchaseProduct.totalpayable = totalPayable - amountPaid; // PurchaseProduct.totalreceivable = 0; // } // CONTROLLER.saveSellerPayment(PurchaseProduct); // PP_SELLERHSITORY.Add(PurchaseProduct); // MessageBox.Show("Amount Paid Saved Successfully!"); // RefreshUsers(); // //setTotalRecievable(); // } //} private void showDetail_Click(object sender, RoutedEventArgs e) { //HCS.History hstry = ((FrameworkElement)sender).DataContext as HCS.History; Khata khata = (Khata)dgSalesHistory.SelectedItem; int id = 0; if (khata.activitycode == ActivityType.Purchase.GetStringValue()) { CONTROLLER.PURCHASEPRODUCT = new purchaseproduct(); //fill data context for purchase Product and then invoke purchase Product screen here. using (var db = new HCSMLEntities1()) { var purchaseproductfromdb = from product in db.purchaseproducts where product.seqid == khata.purchaseproductid select product; CONTROLLER.PURCHASEPRODUCT = (purchaseproduct) purchaseproductfromdb.FirstOrDefault(); CONTROLLER.PURCHASEPRODUCT.isenglishvisible = CONTROLLER.ISENGLISHVISIBLE; CONTROLLER.PURCHASEPRODUCT.isurduvisible = CONTROLLER.ISURDUVISIBLE; } //invoking screen to show purchase detail. winPurchaseProductPopUp wppp = new winPurchaseProductPopUp(CONTROLLER); wppp.Show(); } if (khata.activitycode == ActivityType.Sale.GetStringValue()) { CONTROLLER.SALEPRODUCT = new saleproduct(); using (var db = new HCSMLEntities1()) { var saleproductfromdb = from saleProduct in db.saleproducts where saleProduct.seqid == khata.saleproductid select saleProduct; CONTROLLER.SALEPRODUCT = (saleproduct)saleproductfromdb.FirstOrDefault(); CONTROLLER.SALEPRODUCT.isenglishvisible = CONTROLLER.ISENGLISHVISIBLE; CONTROLLER.SALEPRODUCT.isurduvisible = CONTROLLER.ISURDUVISIBLE; } //invoke sale Product screen winSaleProductPopUp wspp = new winSaleProductPopUp(CONTROLLER); wspp.Show(); } /* individualuser obj = ((FrameworkElement)sender).DataContext as individualuser; obj.isenglishvisible = CONTROLLER.ISENGLISHVISIBLE; obj.isurduvisible = CONTROLLER.ISURDUVISIBLE; individualUser = obj; loadImage(); this.grdIndividualDetail.DataContext = individualUser;*/ }
private string getName(string typecode,int userid) { string retName = ""; using (var db = new HCSMLEntities1()) { if (CONTROLLER.ISENGLISHVISIBLE) { if (typecode == "00001") { retName = (from n in db.individualusers where n.individualid == userid select n.name_e).FirstOrDefault(); } else if (typecode == "00002") { retName = (from n in db.companyusers where n.companyid == userid select n.companyname_e).FirstOrDefault(); } else if (typecode == "00003") { retName = (from n in db.feedmillusers where n.feedmillid == userid select n.feemillname_e).FirstOrDefault(); } else if (typecode == "00004") { retName = (from n in db.bankusers where n.bankid == userid select n.bankname_e).FirstOrDefault(); } } if (CONTROLLER.ISURDUVISIBLE) { if (typecode == "00001") { retName = (from n in db.individualusers where n.individualid == userid select n.name_u).FirstOrDefault(); } else if (typecode == "00002") { retName = (from n in db.companyusers where n.companyid == userid select n.companyname_u).FirstOrDefault(); } else if (typecode == "00003") { retName = (from n in db.feedmillusers where n.feedmillid == userid select n.feedmillname_u).FirstOrDefault(); } else if (typecode == "00004") { retName = (from n in db.bankusers where n.bankid == userid select n.bankname_u).FirstOrDefault(); } } } return retName; }
private string getProductName(int productId) { string retName = ""; using (var db = new HCSMLEntities1()) { if (CONTROLLER.ISENGLISHVISIBLE) { retName = (from p in db.products where p.productid == productId select p.productname_e).FirstOrDefault(); } if (CONTROLLER.ISURDUVISIBLE) { retName = (from p in db.products where p.productid == productId select p.productname_u).FirstOrDefault(); } } return retName; }
private void btnSearch_Click(object sender, RoutedEventArgs e) { HISTORY = new ObservableCollection<Khata>(); if (CONTROLLER.ISENGLISHVISIBLE) { if (cmbSellerType_e.SelectedItem != null && cmbSeller_e.SelectedItem != null) { sellertype sellerType = (sellertype)cmbSellerType_e.SelectedItem; Seller seller = (Seller)cmbSeller_e.SelectedItem; sellertype = sellerType.seller_cde; sellerid = seller.sellerid; //filling the collection as per search criteria using (var db = new HCSMLEntities1()) { var qry = from k in db.Khatas where k.bpid==sellerid select k; foreach (var item in (qry)) { Khata kh = new Khata(); kh.date = item.date; kh.activitycode = item.activitycode; kh.id = item.id; kh.payable_naam = item.payable_naam; kh.productid = item.productid; kh.bpid = item.bpid; kh.purchasertypecode = item.purchasertypecode; kh.receivable_jama = item.receivable_jama; kh.sellertypecode = item.sellertypecode; kh.bpname = getName(kh.sellertypecode, kh.bpid); kh.totalpayable_naam = item.totalpayable_naam; kh.totalreceivable_jama = item.totalreceivable_jama; kh.purchaseproductid = item.purchaseproductid; kh.saleproductid = item.saleproductid; HISTORY.Add(kh); } } //PP_SELLERHSITORY = new ObservableCollection<purchaseproduct>(CONTROLLER.getHistoryPurchaseProduct(sellertype, sellerid)); //SP_SALEHISTORY = new ObservableCollection<saleproduct>(CONTROLLER.getHistorySaleProduct(sellertype, sellerid)); //HISTORY = new ObservableCollection<HCS.History>(fillHistory(SP_SALEHISTORY,PP_SELLERHSITORY)); RefreshUsers(); //setTotalRecievable(); } } if (CONTROLLER.ISURDUVISIBLE) { if (cmbSellerType_u.SelectedItem != null && cmbSeller_u.SelectedItem != null) { sellertype sellerType = (sellertype)cmbSellerType_u.SelectedItem; Seller seller = (Seller)cmbSeller_u.SelectedItem; sellertype = sellerType.seller_cde; sellerid = seller.sellerid; using (var db = new HCSMLEntities1()) { var qry = from k in db.Khatas where k.bpid == sellerid select k; foreach (var item in (qry)) { Khata kh = new Khata(); kh.date = item.date; kh.activitycode = item.activitycode; kh.id = item.id; kh.payable_naam = item.payable_naam; kh.productid = item.productid; kh.bpid = item.bpid; kh.purchasertypecode = item.purchasertypecode; kh.receivable_jama = item.receivable_jama; kh.sellertypecode = item.sellertypecode; kh.bpname = getName(kh.sellertypecode, kh.bpid); kh.totalpayable_naam = item.totalpayable_naam; kh.totalreceivable_jama = item.totalreceivable_jama; kh.productname = getProductName(kh.productid); kh.purchaseproductid = item.purchaseproductid; kh.saleproductid = item.saleproductid; HISTORY.Add(kh); } } //PP_SELLERHSITORY = new ObservableCollection<purchaseproduct>(CONTROLLER.getHistoryPurchaseProduct(sellertype, sellerid)); //SP_SALEHISTORY = new ObservableCollection<saleproduct>(CONTROLLER.getHistorySaleProduct(sellertype, sellerid)); //HISTORY = new ObservableCollection<HCS.History>(fillHistory(SP_SALEHISTORY, PP_SELLERHSITORY)); RefreshUsers(); //setTotalRecievable(); } } }
public HCSController(bool canUserEdit) { dbContext = new HCSMLEntities1(); CANUSEREDIT = canUserEdit; loadIndividual(); loadCompany(); loadBank(); loadFeedMillUsers(); loadPurchasers(); loadSellerType(); loadProducts(); loadSaleType(); loadKhataType(); }
public SaleController() { saleDb = new HCSMLEntities1(); }
private void btnSearch_Click(object sender, RoutedEventArgs e) { HISTORY = new ObservableCollection<OtherKhata>(); string khatatypecode; if (CONTROLLER.ISENGLISHVISIBLE) { if (cmbKhataType_e.SelectedItem != null) { KhataTypeCode khatatype = (KhataTypeCode) cmbKhataType_e.SelectedItem; khatatypecode = khatatype.khatatypecde; //filling the collection as per search criteria using (var db = new HCSMLEntities1()) { var qry = from k in db.OtherKhatas where k.khatatypecde == khatatypecode select k; foreach (var item in (qry)) { OtherKhata kh = new OtherKhata(); kh.date = item.date; kh.activitycode = item.activitycode; kh.id = item.id; kh.payable_naam = item.payable_naam; kh.productname = item.productname; kh.purchaserid = item.purchaserid; kh.purchasertypecode = item.purchasertypecode; kh.receivable_jama = item.receivable_jama; kh.sellerid = item.sellerid; kh.sellertypecode = item.sellertypecode; kh.sellername = getName(kh.sellertypecode, kh.sellerid); kh.purchasername = getName(kh.purchasertypecode, kh.purchaserid); kh.totalpayable_naam = item.totalpayable_naam; kh.totalreceivable_jama = item.totalreceivable_jama; HISTORY.Add(kh); } } RefreshUsers(); //setTotalRecievable(); } } if (CONTROLLER.ISURDUVISIBLE) { if (cmbKhataType_u.SelectedItem != null) { KhataTypeCode khatatype = (KhataTypeCode) cmbKhataType_u.SelectedItem; khatatypecode = khatatype.khatatypecde; //filling the collection as per search criteria using (var db = new HCSMLEntities1()) { var qry = from k in db.OtherKhatas where k.khatatypecde == khatatypecode select k; foreach (var item in (qry)) { OtherKhata kh = new OtherKhata(); kh.date = item.date; kh.activitycode = item.activitycode; kh.id = item.id; kh.payable_naam = item.payable_naam; kh.productname = item.productname; kh.purchaserid = item.purchaserid; kh.purchasertypecode = item.purchasertypecode; kh.receivable_jama = item.receivable_jama; kh.sellerid = item.sellerid; kh.sellertypecode = item.sellertypecode; kh.sellername = getName(kh.sellertypecode, kh.sellerid); kh.purchasername = getName(kh.purchasertypecode, kh.purchaserid); kh.totalpayable_naam = item.totalpayable_naam; kh.totalreceivable_jama = item.totalreceivable_jama; HISTORY.Add(kh); } } RefreshUsers(); //setTotalRecievable(); } } }