public long Insert(PaymentsDebitDetails Details) { try { string SQL = "INSERT INTO tblPaymentDebit (" + "PaymentID, " + "ChartOfAccountID, " + "Amount" + ") VALUES (" + "@PaymentID, " + "@ChartOfAccountID, " + "@Amount" + ");"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmPaymentID = new MySqlParameter("@PaymentID",MySqlDbType.Int64); prmPaymentID.Value = Details.PaymentID; cmd.Parameters.Add(prmPaymentID); MySqlParameter prmChartOfAccountID = new MySqlParameter("@ChartOfAccountID",MySqlDbType.Int64); prmChartOfAccountID.Value = Details.ChartOfAccountID; cmd.Parameters.Add(prmChartOfAccountID); MySqlParameter prmAmount = new MySqlParameter("@Amount",MySqlDbType.Decimal); prmAmount.Value = Details.Amount; cmd.Parameters.Add(prmAmount); 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 long Insert(PaymentsDebitDetails Details) { try { string SQL = "INSERT INTO tblPaymentDebit (" + "PaymentID, " + "ChartOfAccountID, " + "Amount" + ") VALUES (" + "@PaymentID, " + "@ChartOfAccountID, " + "@Amount" + ");"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmPaymentID = new MySqlParameter("@PaymentID", MySqlDbType.Int64); prmPaymentID.Value = Details.PaymentID; cmd.Parameters.Add(prmPaymentID); MySqlParameter prmChartOfAccountID = new MySqlParameter("@ChartOfAccountID", MySqlDbType.Int64); prmChartOfAccountID.Value = Details.ChartOfAccountID; cmd.Parameters.Add(prmChartOfAccountID); MySqlParameter prmAmount = new MySqlParameter("@Amount", MySqlDbType.Decimal); prmAmount.Value = Details.Amount; cmd.Parameters.Add(prmAmount); 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 PaymentsDebitDetails Details(long PaymentDebitID) { try { string SQL = "SELECT " + "PaymentDebitID, " + "PaymentID, " + "a.ChartOfAccountID, " + "ChartOfAccountCode, " + "ChartOfAccountName, " + "Amount " + "FROM tblPaymentDebit a INNER JOIN tblChartOfAccount b " + "ON a.ChartOfAccountID = b.ChartOfAccountID " + "WHERE PaymentDebitID = @PaymentDebitID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmPaymentDebitID = new MySqlParameter("@PaymentDebitID", MySqlDbType.Int64); prmPaymentDebitID.Value = PaymentDebitID; cmd.Parameters.Add(prmPaymentDebitID); 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); PaymentsDebitDetails Details = new PaymentsDebitDetails(); foreach (System.Data.DataRow dr in dt.Rows) { Details.PaymentDebitID = PaymentDebitID; Details.PaymentID = Int64.Parse(dr["PaymentID"].ToString()); Details.ChartOfAccountID = Int32.Parse(dr["ChartOfAccountID"].ToString()); Details.Amount = decimal.Parse(dr["Amount"].ToString()); } return(Details); } catch (Exception ex) { throw base.ThrowException(ex); } }
public void Update(PaymentsDebitDetails Details) { try { string SQL = "UPDATE tblPaymentDebit SET " + "PaymentID = @PaymentID, "+ "ChartOfAccountID = @ChartOfAccountID, "+ "Amount = @Amount "+ "WHERE PaymentDebitID = @PaymentDebitID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmPaymentID = new MySqlParameter("@PaymentID", MySqlDbType.Int64); prmPaymentID.Value = Details.PaymentID; cmd.Parameters.Add(prmPaymentID); MySqlParameter prmChartOfAccountID = new MySqlParameter("@ChartOfAccountID", MySqlDbType.Int64); prmChartOfAccountID.Value = Details.ChartOfAccountID; cmd.Parameters.Add(prmChartOfAccountID); MySqlParameter prmAmount = new MySqlParameter("@Amount", MySqlDbType.Decimal); prmAmount.Value = Details.Amount; cmd.Parameters.Add(prmAmount); MySqlParameter prmPaymentDebitID = new MySqlParameter("@PaymentDebitID", MySqlDbType.Int64); prmPaymentDebitID.Value = Details.PaymentDebitID; cmd.Parameters.Add(prmPaymentDebitID); base.ExecuteNonQuery(cmd); } catch (Exception ex) { throw base.ThrowException(ex); } }
public PaymentsDebitDetails Details(long PaymentDebitID) { try { string SQL = "SELECT " + "PaymentDebitID, " + "PaymentID, " + "a.ChartOfAccountID, " + "ChartOfAccountCode, " + "ChartOfAccountName, " + "Amount " + "FROM tblPaymentDebit a INNER JOIN tblChartOfAccount b " + "ON a.ChartOfAccountID = b.ChartOfAccountID " + "WHERE PaymentDebitID = @PaymentDebitID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmPaymentDebitID = new MySqlParameter("@PaymentDebitID",MySqlDbType.Int64); prmPaymentDebitID.Value = PaymentDebitID; cmd.Parameters.Add(prmPaymentDebitID); 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); PaymentsDebitDetails Details = new PaymentsDebitDetails(); foreach (System.Data.DataRow dr in dt.Rows) { Details.PaymentDebitID = PaymentDebitID; Details.PaymentID = Int64.Parse(dr["PaymentID"].ToString()); Details.ChartOfAccountID = Int32.Parse(dr["ChartOfAccountID"].ToString()); Details.Amount = decimal.Parse(dr["Amount"].ToString()); } return Details; } catch (Exception ex) { throw base.ThrowException(ex); } }
public void Update(PaymentsDebitDetails Details) { try { string SQL = "UPDATE tblPaymentDebit SET " + "PaymentID = @PaymentID, " + "ChartOfAccountID = @ChartOfAccountID, " + "Amount = @Amount " + "WHERE PaymentDebitID = @PaymentDebitID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmPaymentID = new MySqlParameter("@PaymentID",MySqlDbType.Int64); prmPaymentID.Value = Details.PaymentID; cmd.Parameters.Add(prmPaymentID); MySqlParameter prmChartOfAccountID = new MySqlParameter("@ChartOfAccountID",MySqlDbType.Int64); prmChartOfAccountID.Value = Details.ChartOfAccountID; cmd.Parameters.Add(prmChartOfAccountID); MySqlParameter prmAmount = new MySqlParameter("@Amount",MySqlDbType.Decimal); prmAmount.Value = Details.Amount; cmd.Parameters.Add(prmAmount); MySqlParameter prmPaymentDebitID = new MySqlParameter("@PaymentDebitID",MySqlDbType.Int64); prmPaymentDebitID.Value = Details.PaymentDebitID; cmd.Parameters.Add(prmPaymentDebitID); base.ExecuteNonQuery(cmd); } catch (Exception ex) { throw base.ThrowException(ex); } }
private void SaveDebit() { PaymentsDebitDetails clsDetails = new PaymentsDebitDetails(); clsDetails.PaymentID = Convert.ToInt64(lblPaymentID.Text); clsDetails.ChartOfAccountID = Convert.ToInt32(cboAccount.SelectedItem.Value); clsDetails.Amount = Convert.ToDecimal(txtAmount.Text); PaymentsDebit clsPaymentsDebit = new PaymentsDebit(); clsPaymentsDebit.Insert(clsDetails); clsPaymentsDebit.CommitAndDispose(); }