protected void KnockOffTransaction(object sender, EventArgs e) { List <Entities.Billing.KnockOff> transactions = new List <Entities.Billing.KnockOff>(); int voucherId = Convert.ToInt32(ddlKOVoucher.SelectedValue); CurrentSession session = CurrentSession.Current; foreach (GridViewRow gridRow in this.gridKO.Rows) { if (gridRow.RowType == DataControlRowType.DataRow) { CheckBox chk = gridRow.FindControl("chkBxItem") as CheckBox; if (chk != null && chk.Checked && chk.Enabled) { int transactionId = int.Parse(gridKO.DataKeys[gridRow.RowIndex].Values["TransactionId"].ToString()); int paymentTypeId = int.Parse(gridKO.DataKeys[gridRow.RowIndex].Values["PaymentTypeId"].ToString()); Label labelTranTotal = gridRow.FindControl("labeltranTotal") as Label; TextBox textBox = gridRow.FindControl("txtKOAmt") as TextBox; RangeValidator rgKOAmount = gridRow.FindControl("rgKOAmount") as RangeValidator; if (textBox != null && textBox.Text != "" && Convert.ToDouble(textBox.Text.Trim()) > 0.0D && rgKOAmount.IsValid) { double KOAmt = Convert.ToDouble(textBox.Text.Trim()); KnockOff knockOff = new KnockOff() { Id = 0, TransactionId = transactionId, UserId = session.User.Id, PaymentTypeId = paymentTypeId, KnockOffAmount = KOAmt, TransactionAmount = Convert.ToDouble(labelTranTotal.Text.Trim()), DeleteFlag = false, Description = "" }; transactions.Add(knockOff); } } } ; } KnockOffServices servicesKO = new KnockOffServices(); KnockOffServices.ResponseCode responseCode = servicesKO.KnockOffTransaction(session, voucherId, transactions); if (responseCode == KnockOffServices.ResponseCode.Ok) { IQCareMsgBox.NotifyAction("Knock off for the selected* transaction succeeded", "Knock Operation Success", false, this, ""); } else if (responseCode == KnockOffServices.ResponseCode.BadRequest) { IQCareMsgBox.NotifyAction("Knock off for the selected* transaction failed", "Bad Request", true, this, ""); } this.GetContextTabData(TabContainer1.ActiveTabIndex); }
/// <summary> /// Saves the voucher. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void SaveVoucher(object sender, EventArgs e) { try { DateTime valDate = Convert.ToDateTime(txtDate.Text); Double valAmount = Convert.ToDouble(txtAmount.Text); string valType = ddlVoucherType.SelectedValue; string valReference = txtReference.Text; string description = txtDetails.Text; KnockOffServices KOServices = new KnockOffServices(); KnockOffServices.ResponseCode responseCode = KOServices.SaveVoucher(CurrentSession.Current, valDate, valAmount, valType, valReference, description); if (responseCode == KnockOffServices.ResponseCode.Ok) { txtDetails.Text = txtAmount.Text = txtDate.Text = txtReference.Text = txtDate.Text = ""; ddlVoucherType.SelectedIndex = 0; IQCareMsgBox.NotifyAction("Voucher details saved successfully", "Saving Voucher", false, this, ""); } } catch (Exception ex) { IQCareMsgBox.NotifyAction(ex.Message, "Error Saving Voucher", true, this, ""); } }