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); } }