protected void uiGridViewVouchers_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditR") { BLL.PaymentVoucher voucher = new BLL.PaymentVoucher(); voucher.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); CurrentVoucher = voucher; uiTextBoxVoucherNo.Text = voucher.VoucherNumber; if (!voucher.IsColumnNull("VoucherDate")) uiTextBoxVoucherDate.Text = voucher.VoucherDate.ToString("dd/MM/yyyy"); uiTextBoxAmount.Text = voucher.Amount.ToString(); uiCheckBoxIsCheque.Checked = voucher.IsCheque; uiTextBoxBank.Text = voucher.BankName; if (!voucher.IsColumnNull("ChuqueDate")) uiTextBoxChequeDate.Text = voucher.ChuqueDate.ToString("dd/MM/yyyy"); uiTextBoxReason.Text = voucher.Reason; if (!voucher.IsColumnNull(BLL.PaymentVoucher.ColumnNames.PassengerId)) { uiDropDownListCustomer.SelectedValue = voucher.PassengerId.ToString(); } uiTextBoxPaidFor.Text = voucher.PaidFor; uiPanelAll.Visible = false; uiPanelEdit.Visible = true; } else if (e.CommandName == "DeleteR") { BLL.PaymentVoucher voucher = new BLL.PaymentVoucher(); voucher.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); voucher.MarkAsDeleted(); voucher.Save(); LoadAllVouchers(); } }
protected void uiLinkButtonSave_Click(object sender, EventArgs e) { BLL.PaymentVoucher voucher = new BLL.PaymentVoucher(); if (CurrentVoucher == null) voucher.AddNew(); else voucher = CurrentVoucher; voucher.VoucherNumber = uiTextBoxVoucherNo.Text; try { voucher.VoucherDate = DateTime.ParseExact(uiTextBoxVoucherDate.Text, "dd/MM/yyyy", null); } catch (Exception) { } voucher.Amount = decimal.Parse(uiTextBoxAmount.Text); if (uiDropDownListCustomer.SelectedIndex == 0) voucher.PaidFor = uiTextBoxPaidFor.Text; else { voucher.PaidFor = uiDropDownListCustomer.SelectedItem.Text; voucher.PassengerId = Convert.ToInt32(uiDropDownListCustomer.SelectedValue); } voucher.IsCheque = uiCheckBoxIsCheque.Checked; voucher.BankName = uiTextBoxBank.Text; voucher.Reason = uiTextBoxReason.Text; try { voucher.ChuqueDate = DateTime.ParseExact(uiTextBoxChequeDate.Text, "dd/MM/yyyy", null); } catch (Exception) { } voucher.Save(); LoadAllVouchers(); uiPanelAll.Visible = true; uiPanelEdit.Visible = false; ClearFields(); CurrentVoucher = null; }