public PaymentsDetails Details(long PaymentID) { try { string SQL = SQLSelect() + "WHERE PaymentID = @PaymentID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmPaymentID = new MySqlParameter("@PaymentID", MySqlDbType.Int64); prmPaymentID.Value = PaymentID; cmd.Parameters.Add(prmPaymentID); MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult); PaymentsDetails Details = new PaymentsDetails(); while (myReader.Read()) { Details.PaymentID = PaymentID; Details.BankID = myReader.GetInt32("BankID"); Details.BankCode = "" + myReader["BankCode"].ToString(); Details.BankName = "" + myReader["BankName"].ToString(); Details.ChequeDate = myReader.GetDateTime("ChequeDate"); Details.ChequeNo = "" + myReader["ChequeNo"].ToString(); Details.PayeeID = myReader.GetInt64("PayeeID"); Details.PayeeCode = "" + myReader["PayeeCode"].ToString(); Details.PayeeName = "" + myReader["PayeeName"].ToString(); Details.Particulars = "" + myReader["Particulars"].ToString(); Details.Status = (AccountPaymentsStatus)Enum.Parse(typeof(AccountPaymentsStatus), myReader.GetString("Status")); Details.TotalDebitAmount = myReader.GetDecimal("TotalDebitAmount"); Details.TotalCreditAmount = myReader.GetDecimal("TotalCreditAmount"); } myReader.Close(); return(Details); } catch (Exception ex) { throw base.ThrowException(ex); } }
public long Insert(PaymentsDetails Details) { try { string SQL = "INSERT INTO tblPayment (" + "BankID, " + "BankCode, " + "ChequeDate, " + "ChequeNo, " + "PayeeID, " + "PayeeCode, " + "PayeeName, " + "Particulars, " + "Status, " + "TotalDebitAmount, " + "TotalCreditAmount" + ") VALUES (" + "@BankID, " + "@BankCode, " + "@ChequeDate, " + "@ChequeNo, " + "@PayeeID, " + "@PayeeCode, " + "@PayeeName, " + "@Particulars, " + "@Status, " + "@TotalDebitAmount, " + "@TotalCreditAmount" + ");"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmBankID = new MySqlParameter("@BankID", MySqlDbType.Int32); prmBankID.Value = Details.BankID; cmd.Parameters.Add(prmBankID); MySqlParameter prmBankCode = new MySqlParameter("@BankCode", MySqlDbType.String); prmBankCode.Value = Details.BankCode; cmd.Parameters.Add(prmBankCode); MySqlParameter prmChequeDate = new MySqlParameter("@ChequeDate", MySqlDbType.Date); prmChequeDate.Value = Details.ChequeDate.ToString("yyyy-MM-dd"); cmd.Parameters.Add(prmChequeDate); MySqlParameter prmChequeNo = new MySqlParameter("@ChequeNo", MySqlDbType.String); prmChequeNo.Value = Details.ChequeNo; cmd.Parameters.Add(prmChequeNo); MySqlParameter prmPayeeID = new MySqlParameter("@PayeeID", MySqlDbType.Int64); prmPayeeID.Value = Details.PayeeID; cmd.Parameters.Add(prmPayeeID); MySqlParameter prmPayeeCode = new MySqlParameter("@PayeeCode", MySqlDbType.String); prmPayeeCode.Value = Details.PayeeCode; cmd.Parameters.Add(prmPayeeCode); MySqlParameter prmPayeeName = new MySqlParameter("@PayeeName", MySqlDbType.String); prmPayeeName.Value = Details.PayeeName; cmd.Parameters.Add(prmPayeeName); MySqlParameter prmParticulars = new MySqlParameter("@Particulars", MySqlDbType.String); prmParticulars.Value = Details.Particulars; cmd.Parameters.Add(prmParticulars); MySqlParameter prmStatus = new MySqlParameter("@Status", MySqlDbType.Int16); prmStatus.Value = Details.Status.ToString("d"); cmd.Parameters.Add(prmStatus); MySqlParameter prmTotalDebitAmount = new MySqlParameter("@TotalDebitAmount", MySqlDbType.Decimal); prmTotalDebitAmount.Value = Details.TotalDebitAmount; cmd.Parameters.Add(prmTotalDebitAmount); MySqlParameter prmTotalCreditAmount = new MySqlParameter("@TotalCreditAmount", MySqlDbType.Decimal); prmTotalCreditAmount.Value = Details.TotalCreditAmount; cmd.Parameters.Add(prmTotalCreditAmount); base.ExecuteNonQuery(cmd); SQL = "SELECT LAST_INSERT_ID();"; cmd.Parameters.Clear(); cmd.CommandText = SQL; string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); Int64 iID = 0; foreach (System.Data.DataRow dr in dt.Rows) { iID = Int64.Parse(dr[0].ToString()); } return(iID); } catch (Exception ex) { throw base.ThrowException(ex); } }
public void Update(PaymentsDetails Details) { try { string SQL = "UPDATE tblPayment SET " + "BankID = @BankID, "+ "BankCode = @BankCode, "+ "ChequeDate = @ChequeDate, "+ "ChequeNo = @ChequeNo, "+ "PayeeID = @PayeeID, "+ "PayeeCode = @PayeeCode, "+ "PayeeName = @PayeeName, "+ "Particulars = @Particulars, "+ "Status = @Status, "+ "TotalDebitAmount = @TotalDebitAmount, "+ "TotalCreditAmount = @TotalCreditAmount "+ "WHERE PaymentID = @PaymentID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmBankID = new MySqlParameter("@BankID", MySqlDbType.Int32); prmBankID.Value = Details.BankID; cmd.Parameters.Add(prmBankID); MySqlParameter prmBankCode = new MySqlParameter("@BankCode", MySqlDbType.String); prmBankCode.Value = Details.BankCode; cmd.Parameters.Add(prmBankCode); MySqlParameter prmChequeDate = new MySqlParameter("@ChequeDate", MySqlDbType.Date); prmChequeDate.Value = Details.ChequeDate.ToString("yyyy-MM-dd"); cmd.Parameters.Add(prmChequeDate); MySqlParameter prmChequeNo = new MySqlParameter("@ChequeNo", MySqlDbType.String); prmChequeNo.Value = Details.ChequeNo; cmd.Parameters.Add(prmChequeNo); MySqlParameter prmPayeeID = new MySqlParameter("@PayeeID", MySqlDbType.Int64); prmPayeeID.Value = Details.PayeeID; cmd.Parameters.Add(prmPayeeID); MySqlParameter prmPayeeCode = new MySqlParameter("@PayeeCode", MySqlDbType.String); prmPayeeCode.Value = Details.PayeeCode; cmd.Parameters.Add(prmPayeeCode); MySqlParameter prmPayeeName = new MySqlParameter("@PayeeName", MySqlDbType.String); prmPayeeName.Value = Details.PayeeName; cmd.Parameters.Add(prmPayeeName); MySqlParameter prmParticulars = new MySqlParameter("@Particulars", MySqlDbType.String); prmParticulars.Value = Details.Particulars; cmd.Parameters.Add(prmParticulars); MySqlParameter prmStatus = new MySqlParameter("@Status", MySqlDbType.Int16); prmStatus.Value = Details.Status.ToString("d"); cmd.Parameters.Add(prmStatus); MySqlParameter prmTotalDebitAmount = new MySqlParameter("@TotalDebitAmount", MySqlDbType.Decimal); prmTotalDebitAmount.Value = Details.TotalDebitAmount; cmd.Parameters.Add(prmTotalDebitAmount); MySqlParameter prmTotalCreditAmount = new MySqlParameter("@TotalCreditAmount", MySqlDbType.Decimal); prmTotalCreditAmount.Value = Details.TotalCreditAmount; cmd.Parameters.Add(prmTotalCreditAmount); MySqlParameter prmPaymentID = new MySqlParameter("@PaymentID", MySqlDbType.Int64); prmPaymentID.Value = Details.PaymentID; cmd.Parameters.Add(prmPaymentID); base.ExecuteNonQuery(cmd); } catch (Exception ex) { throw base.ThrowException(ex); } }
public long Insert(PaymentsDetails Details) { try { string SQL = "INSERT INTO tblPayment (" + "BankID, " + "BankCode, " + "ChequeDate, " + "ChequeNo, " + "PayeeID, " + "PayeeCode, " + "PayeeName, " + "Particulars, " + "Status, " + "TotalDebitAmount, " + "TotalCreditAmount" + ") VALUES (" + "@BankID, " + "@BankCode, " + "@ChequeDate, " + "@ChequeNo, " + "@PayeeID, " + "@PayeeCode, " + "@PayeeName, " + "@Particulars, " + "@Status, " + "@TotalDebitAmount, " + "@TotalCreditAmount" + ");"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmBankID = new MySqlParameter("@BankID",MySqlDbType.Int32); prmBankID.Value = Details.BankID; cmd.Parameters.Add(prmBankID); MySqlParameter prmBankCode = new MySqlParameter("@BankCode",MySqlDbType.String); prmBankCode.Value = Details.BankCode; cmd.Parameters.Add(prmBankCode); MySqlParameter prmChequeDate = new MySqlParameter("@ChequeDate",MySqlDbType.Date); prmChequeDate.Value = Details.ChequeDate.ToString("yyyy-MM-dd"); cmd.Parameters.Add(prmChequeDate); MySqlParameter prmChequeNo = new MySqlParameter("@ChequeNo",MySqlDbType.String); prmChequeNo.Value = Details.ChequeNo; cmd.Parameters.Add(prmChequeNo); MySqlParameter prmPayeeID = new MySqlParameter("@PayeeID",MySqlDbType.Int64); prmPayeeID.Value = Details.PayeeID; cmd.Parameters.Add(prmPayeeID); MySqlParameter prmPayeeCode = new MySqlParameter("@PayeeCode",MySqlDbType.String); prmPayeeCode.Value = Details.PayeeCode; cmd.Parameters.Add(prmPayeeCode); MySqlParameter prmPayeeName = new MySqlParameter("@PayeeName",MySqlDbType.String); prmPayeeName.Value = Details.PayeeName; cmd.Parameters.Add(prmPayeeName); MySqlParameter prmParticulars = new MySqlParameter("@Particulars",MySqlDbType.String); prmParticulars.Value = Details.Particulars; cmd.Parameters.Add(prmParticulars); MySqlParameter prmStatus = new MySqlParameter("@Status",MySqlDbType.Int16); prmStatus.Value = Details.Status.ToString("d"); cmd.Parameters.Add(prmStatus); MySqlParameter prmTotalDebitAmount = new MySqlParameter("@TotalDebitAmount",MySqlDbType.Decimal); prmTotalDebitAmount.Value = Details.TotalDebitAmount; cmd.Parameters.Add(prmTotalDebitAmount); MySqlParameter prmTotalCreditAmount = new MySqlParameter("@TotalCreditAmount",MySqlDbType.Decimal); prmTotalCreditAmount.Value = Details.TotalCreditAmount; cmd.Parameters.Add(prmTotalCreditAmount); base.ExecuteNonQuery(cmd); SQL = "SELECT LAST_INSERT_ID();"; cmd.Parameters.Clear(); cmd.CommandText = SQL; string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); Int64 iID = 0; foreach (System.Data.DataRow dr in dt.Rows) { iID = Int64.Parse(dr[0].ToString()); } return iID; } catch (Exception ex) { throw base.ThrowException(ex); } }
public PaymentsDetails Details(long PaymentID) { try { string SQL = SQLSelect() + "WHERE PaymentID = @PaymentID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmPaymentID = new MySqlParameter("@PaymentID",MySqlDbType.Int64); prmPaymentID.Value = PaymentID; cmd.Parameters.Add(prmPaymentID); MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult); PaymentsDetails Details = new PaymentsDetails(); while (myReader.Read()) { Details.PaymentID = PaymentID; Details.BankID = myReader.GetInt32("BankID"); Details.BankCode = "" + myReader["BankCode"].ToString(); Details.BankName = "" + myReader["BankName"].ToString(); Details.ChequeDate = myReader.GetDateTime("ChequeDate"); Details.ChequeNo = "" + myReader["ChequeNo"].ToString(); Details.PayeeID = myReader.GetInt64("PayeeID"); Details.PayeeCode = "" + myReader["PayeeCode"].ToString(); Details.PayeeName = "" + myReader["PayeeName"].ToString(); Details.Particulars = "" + myReader["Particulars"].ToString(); Details.Status = (AccountPaymentsStatus)Enum.Parse(typeof(AccountPaymentsStatus), myReader.GetString("Status")); Details.TotalDebitAmount = myReader.GetDecimal("TotalDebitAmount"); Details.TotalCreditAmount = myReader.GetDecimal("TotalCreditAmount"); } myReader.Close(); return Details; } catch (Exception ex) { throw base.ThrowException(ex); } }
public void Update(PaymentsDetails Details) { try { string SQL = "UPDATE tblPayment SET " + "BankID = @BankID, " + "BankCode = @BankCode, " + "ChequeDate = @ChequeDate, " + "ChequeNo = @ChequeNo, " + "PayeeID = @PayeeID, " + "PayeeCode = @PayeeCode, " + "PayeeName = @PayeeName, " + "Particulars = @Particulars, " + "Status = @Status, " + "TotalDebitAmount = @TotalDebitAmount, " + "TotalCreditAmount = @TotalCreditAmount " + "WHERE PaymentID = @PaymentID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmBankID = new MySqlParameter("@BankID",MySqlDbType.Int32); prmBankID.Value = Details.BankID; cmd.Parameters.Add(prmBankID); MySqlParameter prmBankCode = new MySqlParameter("@BankCode",MySqlDbType.String); prmBankCode.Value = Details.BankCode; cmd.Parameters.Add(prmBankCode); MySqlParameter prmChequeDate = new MySqlParameter("@ChequeDate",MySqlDbType.Date); prmChequeDate.Value = Details.ChequeDate.ToString("yyyy-MM-dd"); cmd.Parameters.Add(prmChequeDate); MySqlParameter prmChequeNo = new MySqlParameter("@ChequeNo",MySqlDbType.String); prmChequeNo.Value = Details.ChequeNo; cmd.Parameters.Add(prmChequeNo); MySqlParameter prmPayeeID = new MySqlParameter("@PayeeID",MySqlDbType.Int64); prmPayeeID.Value = Details.PayeeID; cmd.Parameters.Add(prmPayeeID); MySqlParameter prmPayeeCode = new MySqlParameter("@PayeeCode",MySqlDbType.String); prmPayeeCode.Value = Details.PayeeCode; cmd.Parameters.Add(prmPayeeCode); MySqlParameter prmPayeeName = new MySqlParameter("@PayeeName",MySqlDbType.String); prmPayeeName.Value = Details.PayeeName; cmd.Parameters.Add(prmPayeeName); MySqlParameter prmParticulars = new MySqlParameter("@Particulars",MySqlDbType.String); prmParticulars.Value = Details.Particulars; cmd.Parameters.Add(prmParticulars); MySqlParameter prmStatus = new MySqlParameter("@Status",MySqlDbType.Int16); prmStatus.Value = Details.Status.ToString("d"); cmd.Parameters.Add(prmStatus); MySqlParameter prmTotalDebitAmount = new MySqlParameter("@TotalDebitAmount",MySqlDbType.Decimal); prmTotalDebitAmount.Value = Details.TotalDebitAmount; cmd.Parameters.Add(prmTotalDebitAmount); MySqlParameter prmTotalCreditAmount = new MySqlParameter("@TotalCreditAmount",MySqlDbType.Decimal); prmTotalCreditAmount.Value = Details.TotalCreditAmount; cmd.Parameters.Add(prmTotalCreditAmount); MySqlParameter prmPaymentID = new MySqlParameter("@PaymentID",MySqlDbType.Int64); prmPaymentID.Value = Details.PaymentID; cmd.Parameters.Add(prmPaymentID); base.ExecuteNonQuery(cmd); } catch (Exception ex) { throw base.ThrowException(ex); } }
private void SaveRecord(string Sender) { ComputePayment(Sender); PaymentsDetails clsDetails = new PaymentsDetails(); clsDetails.PaymentID = Convert.ToInt64(lblPaymentID.Text); clsDetails.BankID = Convert.ToInt32(cboBank.SelectedItem.Value); clsDetails.BankCode = cboBank.SelectedItem.Text; clsDetails.ChequeDate = Convert.ToDateTime(txtChequeDate.Text); clsDetails.ChequeNo = txtChequeNo.Text; clsDetails.PayeeID = Convert.ToInt64(cboPayee.SelectedItem.Value); clsDetails.PayeeCode = cboPayee.SelectedItem.Text; clsDetails.PayeeName = txtPayeeName.Text; clsDetails.Particulars = txtRemarks.Text; clsDetails.TotalDebitAmount = Convert.ToDecimal(lblTotalDebitAmount.Text); clsDetails.TotalCreditAmount = Convert.ToDecimal(lblTotalCreditAmount.Text); Payments clsPayments = new Payments(); clsPayments.Update(clsDetails); Banks clsBank = new Banks(clsPayments.Connection, clsPayments.Transaction); clsBank.UpdateChequeCounter(clsDetails.BankID, clsDetails.ChequeNo); clsPayments.CommitAndDispose(); }