protected void btnDiscardCashReport_Click(object sender, EventArgs e) { int id = GXGridView1SelectedValue; if (GXGridView1.SelectedIndex != -1) { if (GXGridView1.SelectedValue != null) { id = Convert.ToInt32(GXGridView1.SelectedValue); } else { id = GXGridView1SelectedValue; } CashReport cr = CashReport.Get(id); if (cr.CashReportStatuse.Code == CashReportStatuse.ODOBRENO) { RegisterStartupScript("myAlert", "<script>alert('НЕ МОЖЕ ДА СЕ СТОРНИРА ОДОБРЕН КАСОВ ИЗВЕШТАЈ!')</script>"); return; } else { CashReport.DiscardCashReport(id); GXGridView1.TotalRecords = ViewCashReport.SelectByFKCountCached("BranchID", this.PageUser.BranchID); GXGridView1.DataBind(); } } }
public ActionResult DeleteConfirmed(int id) { CashReport cashReport = db.CashReports.Find(id); db.CashReports.Remove(cashReport); db.SaveChanges(); return(RedirectToAction("Index")); }
protected void btnPrintCashReport_Click(object sender, EventArgs e) { if (ViewState["CashReportID"] != null) { CashReport cr = CashReport.Get(Convert.ToInt32(ViewState["CashReportID"])); PrintCashReports.PrintCashReport(cr); } }
public ActionResult Edit([Bind(Include = "ID,Date,ProjectName,LastMonthRemain,SubTotalInput,SubTotalOutput,BankRemain,CashInHand,ProjectTotal,CreateDate,CreateBy,Note,Status")] CashReport cashReport) { if (ModelState.IsValid) { db.Entry(cashReport).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cashReport)); }
protected void btnPintCashReport_Click(object sender, EventArgs e) { int id = GXGridView1SelectedValue; if (id > 0) { CashReport cr = CashReport.Get(id); PrintCashReports.PrintCashReport(cr); } }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CashReport cashReport = db.CashReports.Find(id); if (cashReport == null) { return(HttpNotFound()); } return(View(cashReport)); }
protected void btnCreate_Click(object sender, EventArgs e) { List <PaymentInfo> lastPaymentInfos = listPaymentInfos; GridViewRowCollection displayedRows = gvNewPolicies.Rows; foreach (GridViewRow gvRow in displayedRows) { CheckBox cbIsForCashReporting = gvRow.FindControl("cbIsForCashReporting") as CheckBox; int paymentInfoID = Convert.ToInt32(gvNewPolicies.DataKeys[gvRow.RowIndex].Value); PaymentInfo payI = lastPaymentInfos.Where(f => f.ID == paymentInfoID).SingleOrDefault(); payI.IsForCashReporting = cbIsForCashReporting.Checked; } listPaymentInfos = lastPaymentInfos; List <PaymentInfo> listPaymentInfo = listPaymentInfos.Where(c => c.IsForCashReporting == true).ToList(); if (listPaymentInfo.Count > 0) { DateTime reportDate = DateTime.Parse(tbReportDate.Text); CashReport cr = new CashReport(); cr.Number = CashReport.GetNextNumber(this.PageUser.Branch); cr.BranchID = this.PageUser.BranchID; cr.CashReportDate = reportDate; cr.CashReportStatusID = CashReportStatuse.GetByCode(CashReportStatuse.ZA_ODOBRUVANjE).ID; cr.Discard = false; cr.IsAccountBooked = false; cr.TotalValue = 0; cr.Insert(); decimal totValue = 0; foreach (PaymentInfo payI in listPaymentInfo) { totValue += payI.Value; CashReportItem cri = new CashReportItem(); cri.PaymentID = payI.ID; cri.CashReportID = cr.ID; cri.IsActive = true; cri.Insert(); Payment uPayment = Payment.Get(payI.ID); uPayment.IsCashReported = true; Payment.Table.Context.SubmitChanges(); } CashReport crTmp = CashReport.Get(cr.ID); crTmp.TotalValue = totValue; CashReport.Table.Context.SubmitChanges(); btnPrintCashReport.Enabled = true; ViewState["CashReportID"] = cr.ID; } }
protected void btnUpdateStatus_Click(object sender, EventArgs e) { int id = GXGridView1SelectedValue; if (id > 0) { RadioButtonList rblStatuses = (RadioButtonList)dvChangeStatus.FindControl("rblStatuses"); CashReport cr = CashReport.Get(id); if (rblStatuses.SelectedValue == "ODOBRENO") { cr.CashReportStatusID = CashReportStatuse.GetByCode(CashReportStatuse.ODOBRENO).ID; } else if (rblStatuses.SelectedValue == "VRATENO") { cr.CashReportStatusID = CashReportStatuse.GetByCode(CashReportStatuse.VRATENO).ID; } cr.ApproverUserID = this.PageUser.ID; cr.ApproverDate = DateTime.Now; CashReport.Table.Context.SubmitChanges(); GXGridView1.TotalRecords = ViewCashReport.SelectCountCached(); GXGridView1.DataBind(); mvMain.SetActiveView(viewGrid); } }
public static void PrintCashReport(CashReport cr) { PDFCreators creator = new PDFCreators(true, 15, 15, 15, 15); creator.OpenPDF(); creator.GetContentByte(); creator.AddJDBLogoForFactures(10, 775); creator.SetTitleLeft10(" "); creator.SetTitleLeft10(" "); creator.SetTitleLeft10(" "); if (cr.Discard) { creator.SetTitleCenterForFactureNumber("СТОРНИРАН КАСОВ ИЗВЕШТАЈ бр. " + cr.Number); } else { creator.SetTitleCenterForFactureNumber("КАСОВ ИЗВЕШТАЈ бр. " + cr.Number); } creator.SetTitleLeft10("Статус: " + cr.CashReportStatuse.Name); creator.SetTitleLeft10("Датум: " + cr.CashReportDate.ToShortDateString()); creator.SetTitleLeft10("Филијала: " + cr.Branch.Code + " " + cr.Branch.Name); List <CashReportItem> lstCRI = CashReportItem.GetByCashReport(cr.ID); creator.SetTitleLeft10(" "); creator.SetTitleLeft10("Кеш уплата"); Broker.DataAccess.PaymentType ptCash = Broker.DataAccess.PaymentType.GetByCode(Broker.DataAccess.PaymentType.CASH); List <CashReportItem> cashList = lstCRI.Where(c => c.Payment.PaymentTypeID == ptCash.ID).ToList(); string[] headers = { "Ред. бр.", "Број на полиса", "Компанија", "Подкласа", "Договорувач", "Уплата" }; float[] widthPercentages = { 8, 10, 17, 18, 32, 15 }; TypeCode[] typeCodes = { TypeCode.Int32, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.Decimal }; creator.CreateTable_Facture(headers.Length, headers, widthPercentages); object[] values; int ordinalNumber = 1; decimal totCash = 0; foreach (CashReportItem cri in cashList) { values = new object[headers.Length]; values[0] = ordinalNumber.ToString(); values[1] = cri.Payment.Rate.PolicyItem.PolicyNumber; values[2] = cri.Payment.Rate.PolicyItem.Policy.InsuranceCompany.ShortName; values[3] = cri.Payment.Rate.PolicyItem.InsuranceSubType.ShortDescription; values[4] = cri.Payment.Rate.PolicyItem.Policy.Client.Name; values[5] = String.Format("{0:#,0.00}", cri.Payment.Value); creator.AddDataRowForFactures(values, headers.Length, typeCodes); ordinalNumber++; totCash += cri.Payment.Value; } values = new object[headers.Length]; values[0] = ""; values[1] = ""; values[2] = ""; values[3] = ""; values[4] = "Вкупно"; values[5] = String.Format("{0:#,0.00}", totCash); creator.AddDataRowForFactures(values, headers.Length, typeCodes); creator.AddTable(); creator.SetTitleLeft10(" "); creator.SetTitleLeft10("Кредитни картички"); Broker.DataAccess.PaymentType ptCreditCard = Broker.DataAccess.PaymentType.GetByCode(Broker.DataAccess.PaymentType.CREDITCARD); List <CashReportItem> creditCardList = lstCRI.Where(c => c.Payment.PaymentTypeID == ptCreditCard.ID).ToList(); string[] headersCC = { "Ред. бр.", "Број на полиса", "Компанија", "Подкласа", "Договорувач", "Банка", "Уплата" }; float[] widthPercentagesCC = { 7, 9, 16, 17, 27, 10, 14 }; TypeCode[] typeCodesCC = { TypeCode.Int32, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.String, TypeCode.Decimal }; creator.CreateTable_Facture(headersCC.Length, headersCC, widthPercentagesCC); object[] valuesCC; int ordinalNumberCC = 1; decimal totCreditCard = 0; foreach (CashReportItem cri in creditCardList) { valuesCC = new object[headersCC.Length]; valuesCC[0] = ordinalNumberCC.ToString(); valuesCC[1] = cri.Payment.Rate.PolicyItem.PolicyNumber; valuesCC[2] = cri.Payment.Rate.PolicyItem.Policy.InsuranceCompany.ShortName; valuesCC[3] = cri.Payment.Rate.PolicyItem.InsuranceSubType.ShortDescription; valuesCC[4] = cri.Payment.Rate.PolicyItem.Policy.Client.Name; if (cri.Payment.BankCreditCardID != null) { valuesCC[5] = cri.Payment.BankCreditCard.Bank.Name; } else { valuesCC[5] = ""; } valuesCC[6] = String.Format("{0:#,0.00}", cri.Payment.Value); creator.AddDataRowForFactures(valuesCC, headersCC.Length, typeCodesCC); ordinalNumberCC++; totCreditCard += cri.Payment.Value; } valuesCC = new object[headersCC.Length]; valuesCC[0] = ""; valuesCC[1] = ""; valuesCC[2] = ""; valuesCC[3] = ""; valuesCC[4] = ""; valuesCC[5] = "Вкупно"; valuesCC[6] = String.Format("{0:#,0.00}", totCreditCard); creator.AddDataRowForFactures(valuesCC, headersCC.Length, typeCodesCC); creator.AddTable(); creator.SetTitleLeft10(" "); creator.SetTitleRightBold14("Вкупно: " + String.Format("{0:#,0.00}", (totCreditCard + totCash))); creator.FinishPDF_FileName("KasovIzvestaj" + cr.ID); }
public ActionResult Approve(int?cash_spending_id) { if (cash_spending_id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Cash cash = db.Cashes.Find(cash_spending_id); if (cash == null) { return(HttpNotFound()); } var isExistDate = db.CashReports.Any(x => x.Date == cash.C_Date && x.ProjectName == cash.ProjectName); if (isExistDate) { var this_Date = db.CashReports.FirstOrDefault(x => x.Date == cash.C_Date && x.ProjectName == cash.ProjectName); if (this_Date != null) { this_Date.SubTotalInput += cash.Input; } } else { var thisMonth_Report = db.CashReports.Where(x => x.Date.Year == cash.C_Date.Year && x.Date.Month == cash.C_Date.Month).OrderBy(x => x.Date).ToList(); var sumInput = db.Cashes.Where(x => x.C_Date.Month == cash.C_Date.Month && x.C_Date.Year == cash.C_Date.Year && x.C_Date.Day < cash.C_Date.Day).Sum(y => y.Input); var sumOutput = db.Cashes.Where(x => x.C_Date.Month == cash.C_Date.Month && x.C_Date.Year == cash.C_Date.Year && x.C_Date.Day < cash.C_Date.Day).Sum(y => y.Output); var decimal_sumInput = sumInput == null? 0 :sumInput; var decimal_sumOutput = sumOutput == null ? 0 : sumOutput; CashReport cashreport = new CashReport(); cashreport.Date = cash.C_Date; cashreport.ProjectName = cash.ProjectName; cashreport.SubTotalOutput = decimal_sumOutput + cash.Output; cashreport.SubTotalInput = decimal_sumInput + cash.Input; cashreport.CreateDate = DateTime.Now; cashreport.Status = true; cashreport.CreateBy = Request.Cookies["username"] == null ? "" : Request.Cookies["username"].Value; if (cash.C_Date.Day != 1) { CashReport firstDate = thisMonth_Report.FirstOrDefault(); if (firstDate != null) { cashreport.LastMonthRemain = firstDate.LastMonthRemain; } } else { if (cash.C_Date.Month != 1) { var thismouth = db.CashReports.Where(x => x.Date.Year == cash.C_Date.Year && x.Date.Month == (cash.C_Date.Month - 1)).OrderByDescending(x => x.Date).FirstOrDefault(); if (thismouth != null) { cashreport.LastMonthRemain = thismouth.LastMonthRemain; } } else { var thismouth = db.CashReports.Where(x => x.Date.Year == (cash.C_Date.Year - 1) && x.Date.Month == 12).FirstOrDefault(); if (thismouth != null) { cashreport.LastMonthRemain = thismouth.LastMonthRemain; } } } db.CashReports.Add(cashreport); } cash.Status = true; db.SaveChanges(); return(RedirectToAction("Spending")); }