public BillAdjust getBillAdjust(SqlConnection con, int BillsAdjID) { BillAdjust objBAdj = null; try { SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM T_Bills_Adjust WHERE BillAdjustID = @BillAdjustID", con); da.SelectCommand.Parameters.Add("@BillAdjustID", SqlDbType.Int).Value = BillsAdjID; DataTable dt = new DataTable(); da.Fill(dt); da.Dispose(); if (dt.Rows.Count == 0) { return(null); } objBAdj = new BillAdjust(); objBAdj.BillAdjustID = dt.Rows[0].Field <int>("BillAdjustID"); objBAdj.BillsID = dt.Rows[0].Field <int>("BillsID"); objBAdj.AdjustDate = dt.Rows[0].Field <DateTime>("AdjustDate"); objBAdj.AdjustAmount = GlobalFunctions.isNull(dt.Rows[0].Field <object>("AdjustAmount"), (double)0.0); objBAdj.AdjustAccountID = GlobalFunctions.isNull(dt.Rows[0].Field <object>("AdjustAccID"), -1); objBAdj.AdjustMethodID = GlobalFunctions.isNull(dt.Rows[0].Field <object>("AdustMethodID"), -1); objBAdj.AdjustRefNo = GlobalFunctions.isNull(dt.Rows[0].Field <object>("AdjustRefNo"), string.Empty); objBAdj.Remarks = GlobalFunctions.isNull(dt.Rows[0].Field <object>("Remarks"), string.Empty); objBAdj.TransRefID = GlobalFunctions.isNull(dt.Rows[0].Field <object>("TransRefID"), -1); objBAdj.TransVoucherNo = GlobalFunctions.isNull(dt.Rows[0].Field <object>("TransVoucherNo"), string.Empty); } catch (Exception ex) { throw ex; } return(objBAdj); }
public int SaveUpdateBillsAdjust(SqlConnection con, SqlTransaction trans, BillAdjust objBillsA) { int ID = 0; try { SqlCommand cmd = new SqlCommand("spSaveUpdateBillAdjust", con, trans); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@BillAdjustID", SqlDbType.Int).Value = objBillsA.BillAdjustID; cmd.Parameters.Add("@BillsID", SqlDbType.Int).Value = objBillsA.BillsID; cmd.Parameters.Add("@AdjustDate", SqlDbType.DateTime).Value = objBillsA.AdjustDate; cmd.Parameters.Add("@AdjustAmount", SqlDbType.Money).Value = objBillsA.AdjustAmount; cmd.Parameters.Add("@AdjustAccID", SqlDbType.Int).Value = objBillsA.AdjustAccountID; cmd.Parameters.Add("@AdjustMethodID", SqlDbType.Int).Value = objBillsA.AdjustMethodID; if (objBillsA.AdjustRefLCID <= 0) { cmd.Parameters.Add("@AdjustRefLCID", SqlDbType.Int).Value = DBNull.Value; } else { cmd.Parameters.Add("@AdjustRefLCID", SqlDbType.Int).Value = objBillsA.AdjustRefLCID; } cmd.Parameters.Add("@AdjustRefNo", SqlDbType.VarChar, 100).Value = objBillsA.AdjustRefNo; cmd.Parameters.Add("@Remarks", SqlDbType.VarChar, 500).Value = objBillsA.Remarks; if (objBillsA.TransRefID <= 0) { cmd.Parameters.Add("@TransRefID", SqlDbType.Int).Value = DBNull.Value; } else { cmd.Parameters.Add("@TransRefID", SqlDbType.Int).Value = objBillsA.TransRefID; } cmd.Parameters.Add("@TransVoucherNo", SqlDbType.VarChar, 100).Value = objBillsA.TransVoucherNo; if (objBillsA.AcceptDate == new DateTime(1900, 1, 1)) { cmd.Parameters.Add("@AcceptDate", SqlDbType.DateTime).Value = DBNull.Value; } else { cmd.Parameters.Add("@AcceptDate", SqlDbType.DateTime).Value = objBillsA.AcceptDate; } if (objBillsA.MaturityDate == new DateTime(1900, 1, 1)) { cmd.Parameters.Add("@MaturityDate", SqlDbType.DateTime).Value = DBNull.Value; } else { cmd.Parameters.Add("@MaturityDate", SqlDbType.DateTime).Value = objBillsA.MaturityDate; } cmd.Parameters.Add("@BillAccID", SqlDbType.Int).Value = objBillsA.BillAccountID; cmd.Parameters.Add("@CurrencyID", SqlDbType.Int).Value = objBillsA.CurrencyID; cmd.Parameters.Add("@CurrencyRate", SqlDbType.Money).Value = objBillsA.CurrencyRate; cmd.ExecuteNonQuery(); //if (objBillsA.BillAdjustID == 0) //{ // SqlCommand com = new SqlCommand("SELECT ISNULL(MAX(BillAdjustID),0) FROM T_Bills_Adjust", con, trans); // ID = Convert.ToInt32(com.ExecuteScalar()); //} //else // ID = objBillsA.BillAdjustID; } catch (Exception ex) { throw ex; } return(ID); }