public PrepareReport(SellingInvoice sellingInvoice) { this.dictionary = new Dictionary <String, String>(); //addToday(); //addCommon(); addSellingInvoicePara(sellingInvoice); }
//////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// internal void UserControl_Loaded() { try { DailyInitialCash dailyInitialCash = getDailyInitialCashByDate(DateTime.Today); if (dailyInitialCash != null) { dailyInitialCashManager.textBox_initialCashAmount.DoubleValue = dailyInitialCash.Amount; } else { dailyInitialCashManager.textBox_initialCashAmount.DoubleValue = 0; } double totalIncome = 0; SellingCash sellingCash_request = new SellingCash(); sellingCash_request.Date = DateTime.Today; List <SellingCash> listSellingCash = paymentManagerImpl.getSellingCash(sellingCash_request); foreach (SellingCash sellingCash_a in listSellingCash) { totalIncome += sellingCash_a.Amount; } SellingInvoice sellingInvoice_request = new SellingInvoice(); sellingInvoice_request.Date = DateTime.Today; List <SellingInvoice> listSellingInvoice = sellingInvoiceManagerImpl.getInvoice(sellingInvoice_request); foreach (SellingInvoice sellingInvoice_a in listSellingInvoice) { totalIncome -= sellingInvoice_a.ReferrerCommision; } dailyInitialCashManager.textBox_totalIncome.Text = totalIncome.ToString("#,##0.00"); double totalExpences = 0; BuyingCash buyingCash_request = new BuyingCash(); buyingCash_request.Date = DateTime.Today; List <BuyingCash> listBuyingCash = paymentManagerImpl.getBuyingCash(buyingCash_request); foreach (BuyingCash buyingCash_a in listBuyingCash) { totalExpences += buyingCash_a.Amount; } Expense expense_request = new Expense(); expense_request.Date = DateTime.Today; List <Expense> listExpense = expenseManagerImpl.get(expense_request); foreach (Expense expense_a in listExpense) { totalExpences += expense_a.Amount; } dailyInitialCashManager.textBox_totalExpences.Text = totalExpences.ToString("#,##0.00"); dailyInitialCashManager.textBox_finalCashAmount.Text = getFinalCashAmount(Convert.ToDouble(dailyInitialCashManager.textBox_initialCashAmount.Text), totalIncome, totalExpences, Convert.ToDouble(string.IsNullOrWhiteSpace(dailyInitialCashManager.textBox_otherWidthraw.Text) ? "0" : dailyInitialCashManager.textBox_otherWidthraw.Text)).ToString("#,##0.00"); } catch (Exception) { } }
private void BunifuButton1_Click(object sender, EventArgs e) { if (btnAdd.Text == "Add New") { DialogResult msg = MessageBox.Show("Do you confirm to proceed the operation ?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (msg == DialogResult.Yes) { foreach (DataGridViewRow row in dgvMaterials.Rows) { if (Convert.ToInt32(row.Cells[2].Value.ToString()) > Convert.ToInt32(row.Cells[3].Value.ToString())) { m = m + 1; st = row.Cells[0].Value.ToString() + ", " + st; } } if (m == 0) { try { var NomclaID = _unitOfWork.Nomenclature.SingleOrDefault(c => c.Designation == dwnNomcl.selectedValue).Id; var length = Convert.ToSingle(txtLength.Text); var Client = _unitOfWork.Clients.SingleOrDefault(c => c.Company == dwnClient.selectedValue).Id; var discount = Convert.ToSingle(txtDiscount.Text); var price = Convert.ToSingle(txtPrice.Text); var PSt = Pstatus(); var PType = Ptype(); BL.Domain.FabricationOrder fo = new BL.Domain.FabricationOrder { NomenclatureId = NomclaID, Length = length, Status = BL.Domain.FabricationOrder.stat.Pending, CreationDate = DateTime.Today, StartingDate = DateTime.Today }; _unitOfWork.FabricationOrder.InsertOrUpdate(fo); SellingInvoice si = new SellingInvoice { FabricationOrder = fo, ClientId = Client, Price = price, Discount = discount, PaymentStatus = PSt, PaymentType = PType, UserId = usrId, CreatedDate = DateTime.Today }; _unitOfWork.SellingInvoices.InsertOrUpdate(si); foreach (DataGridViewRow r in dgvMaterials.Rows) { var compName = r.Cells[0].Value.ToString(); var TotalMass = Convert.ToSingle(r.Cells[2].Value.ToString()); var AvailRawMList = _unitOfWork.RawMaterials.AllRawMaterials() .Where(c => c.Status == RawMaterial.RMStatus.Available || c.Status == RawMaterial.RMStatus.Reserved && c.Composant.Name == compName) .OrderBy(c => c.Mass).ToList(); int i = 0; if (AvailRawMList.Count > 0) { if (AvailRawMList[i].Mass > TotalMass) { var rest = AvailRawMList[i].Mass - TotalMass; UsedRawMaterial urm = new UsedRawMaterial { FabricationOrder = fo, RawMaterial = AvailRawMList[i], Weight = rest }; _unitOfWork.UsedRawMaterial.InsertOrUpdate(urm); var rawMaterial = _unitOfWork.RawMaterials.Find(AvailRawMList[i].ID); rawMaterial.Status = RawMaterial.RMStatus.Reserved; _unitOfWork.RawMaterials.InsertOrUpdate(rawMaterial); i++; } else { UsedRawMaterial urm = new UsedRawMaterial { FabricationOrder = fo, RawMaterial = AvailRawMList[i], Weight = 0 }; _unitOfWork.UsedRawMaterial.InsertOrUpdate(urm); var rawMaterial = _unitOfWork.RawMaterials.Find(AvailRawMList[i].ID); rawMaterial.Status = RawMaterial.RMStatus.Reserved; _unitOfWork.RawMaterials.InsertOrUpdate(rawMaterial); } _unitOfWork.Complete(); } else { MessageBox.Show("There isn't enought Raw Material Available", "Warning" , MessageBoxButtons.OK, MessageBoxIcon.Warning); } } MessageBox.Show("You Have Successfully Created Selling Invoice", "Succes" , MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("These Components " + st + " Are Unsufficient " + "To launch The Fab Order ", "Warning" , MessageBoxButtons.OK, MessageBoxIcon.Warning); st = ""; } } } else { var s = _unitOfWork.SellingInvoices.Find(SellingID); var client = _unitOfWork.Clients.SingleOrDefault(c => c.Company == dwnClient.selectedValue); s.Client = client; s.Price = Convert.ToSingle(txtPrice.Text); s.Discount = Convert.ToSingle(txtDiscount.Text); s.PaymentStatus = Pstatus(); s.PaymentType = Ptype(); _unitOfWork.SellingInvoices.InsertOrUpdate(s); _unitOfWork.Complete(); MessageBox.Show("You Successfully Updated Selling Invoice", "Success", MessageBoxButtons.OK); this.Hide(); } this.Hide(); }
private void addSellingInvoicePara(SellingInvoice sellingInvoice) { try { TextInfo myTI = new CultureInfo("en-US", false).TextInfo; //addParameter("reportType", "Selling Invoice"); addParameter("shopName", myTI.ToUpper(Session.Preference["shopName"])); addParameter("shopAddress1", myTI.ToUpper(Session.Preference["shopAddress1"])); addParameter("shopAddress2", myTI.ToUpper(Session.Preference["shopAddress2"])); addParameter("shopAddress3", myTI.ToUpper(Session.Preference["shopAddress3"])); addParameter("shopTelephone", myTI.ToUpper(Session.Preference["shopTelephone"])); string sellingInvoicePrint_language = Session.Preference["sellingInvoicePrint_language"]; string showDiscountOrOurPrice = Session.Preference["sellingInvoicePrint_showDiscountOrOurPrice"]; addParameter("reportDate", sellingInvoice.Date.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd") ? DateTime.Now.ToString("G") : sellingInvoice.Date.ToString("yyyy-MM-dd")); addParameter("reportInvoice", sellingInvoice.InvoiceNumber); addParameter("message", Session.Preference["sellingInvoicePrint_message"]); addParameter("signature", sellingInvoice.IsCompletelyPaid == 0 ? "\n............." : ""); if (sellingInvoicePrint_language == "d") { addParameter("ct_reportInvoice", sellingInvoice.IsCompletelyPaid == 1 ? "INVOICE NO " : "CREDIT INVOICE NO "); addParameter("ct_userName", "CASHIER"); addParameter("ct_customerName", "Cus. Name"); addParameter("ct_printedPrice", "PRICE"); addParameter("ct_discountOrPrice", showDiscountOrOurPrice == "d" ? "DIS" : "OUR"); addParameter("ct_quantity", "QTY"); addParameter("ct_lineTotal", "LINE TOTAL"); addParameter("ct_subTotal", "SUB TOTAL"); addParameter("ct_numberOfItems", "Num. Of Items"); addParameter("ct_billDiscount", "BILL DISCOUNT"); addParameter("ct_totalReturn", "TOTAL RETURN"); addParameter("ct_netTotal", "NET TOTAL"); addParameter("ct_givenMoney", "GIVEN MONEY"); addParameter("ct_totalMoney", sellingInvoice.IsQuickPaid == 1 ? "" : "TOTAL PAYMENT"); addParameter("ct_balance", "BALANCE"); } else if (sellingInvoicePrint_language == "c") { addParameter("ct_reportInvoice", sellingInvoice.IsCompletelyPaid == 1 ? Session.Preference["sellingInvoicePrint_invoiceNumber_customLanguageText"] : Session.Preference["sellingInvoicePrint_creditInvoice_customLanguageText"]); addParameter("ct_userName", Session.Preference["sellingInvoicePrint_userName_customLanguageText"]); addParameter("ct_customerName", Session.Preference["sellingInvoicePrint_customerName_customLanguageText"]); addParameter("ct_printedPrice", Session.Preference["sellingInvoicePrint_printedPrice_customLanguageText"]); addParameter("ct_discountOrPrice", Session.Preference[(showDiscountOrOurPrice == "o" ? "sellingInvoicePrint_ourPrice_customLanguageText" : "sellingInvoicePrint_discount_customLanguageText")]); addParameter("ct_quantity", Session.Preference["sellingInvoicePrint_quantity_customLanguageText"]); addParameter("ct_lineTotal", Session.Preference["sellingInvoicePrint_lineTotal_customLanguageText"]); addParameter("ct_subTotal", Session.Preference["sellingInvoicePrint_subTotal_customLanguageText"]); addParameter("ct_numberOfItems", Session.Preference["sellingInvoicePrint_numberOfItems_customLanguageText"]); addParameter("ct_billDiscount", Session.Preference["sellingInvoicePrint_billDiscount_customLanguageText"]); addParameter("ct_totalReturn", Session.Preference["sellingInvoicePrint_totalReturn_customLanguageText"]); addParameter("ct_netTotal", Session.Preference["sellingInvoicePrint_netTotal_customLanguageText"]); addParameter("ct_givenMoney", Session.Preference["sellingInvoicePrint_givenMoney_customLanguageText"]); addParameter("ct_totalMoney", sellingInvoice.IsQuickPaid == 1 ? "" : Session.Preference["sellingInvoicePrint_totalPayment_customLanguageText"]); addParameter("ct_balance", Session.Preference["sellingInvoicePrint_balance_customLanguageText"]); } addParameter("thankyouText", Session.Preference["sellingInvoicePrint_thankyouText"]); //ShowMessage.error(addSellingInvoice.textBox_balance_selectedItems.Text); addParameter("footerText", Session.Preference["sellingInvoiceFooterText"].Replace("$", "" + System.Environment.NewLine)); //addParameter("reportDescription", "Test text"); //addReportPeriod(null, null); /**/ } catch (Exception) { } }