public int SaveAcr(AcrDB objDB,SqlTransaction objTrans) { int ID = 0; DataAccessLayer objDataLayer = new DataAccessLayer(); SqlCommand objCmd = new SqlCommand(); try { objCmd.CommandText = "usp_AcrInsert"; objCmd.CommandType = CommandType.StoredProcedure; objCmd.Parameters.AddWithValue("@WCDOCNO", objDB.WCDOCNO); objCmd.Parameters.AddWithValue("@DLR_REF", objDB.DLR_REF); objCmd.Parameters.AddWithValue("@TRACTOR_NO", objDB.TRACTOR_NO); objCmd.Parameters.AddWithValue("@ENGINE_NO", objDB.ENGINE_NO); objCmd.Parameters.AddWithValue("@INS_DATE", objDB.INS_DATE); objCmd.Parameters.AddWithValue("@DEF_DATE", objDB.DEF_DATE); objCmd.Parameters.AddWithValue("@REP_DATE", objDB.REP_DATE); objCmd.Parameters.AddWithValue("@HMR", objDB.HMR); objCmd.Parameters.AddWithValue("@DLR_CO", objDB.DLR_CO); objCmd.Parameters.AddWithValue("@DEALER_NAME", objDB.DEALER_NAME); objCmd.Parameters.AddWithValue("@REG", objDB.REG); objCmd.Parameters.AddWithValue("@CR_DATE", objDB.CR_DATE); objCmd.Parameters.AddWithValue("@ITEM_CODE", objDB.ITEM_CODE); objCmd.Parameters.AddWithValue("@DESCRIPTION", objDB.DESCRIPTION); objCmd.Parameters.AddWithValue("@QUANTITY", objDB.QUANTITY); objCmd.Parameters.AddWithValue("@COST", objDB.COST); objCmd.Parameters.AddWithValue("@DEF", objDB.DEF); objCmd.Parameters.AddWithValue("@NDP", objDB.NDP); objCmd.Parameters.AddWithValue("@VALUE", objDB.VALUE); objCmd.Parameters.AddWithValue("@CVOICE", objDB.CVOICE); objCmd.Parameters.AddWithValue("@OUTLV", objDB.OUTLV); objCmd.Parameters.AddWithValue("@DT", objDB.DT); objCmd.Parameters.AddWithValue("@CUL_CODE", objDB.CUL_CODE); objCmd.Parameters.AddWithValue("@BLANK", objDB.BLANK); objCmd.Parameters.AddWithValue("@CR_AMOUNT", objDB.CR_AMOUNT); objCmd.Parameters.AddWithValue("@AUTH_AMT", objDB.AUTH_AMOUNT); objCmd.Parameters.AddWithValue("@DIFF", objDB.DIFF); objCmd.Parameters.AddWithValue("@Production_Month", objDB.Production_Month); objCmd.Parameters.AddWithValue("@Production_Month_Year", objDB.Production_Month_Year); objCmd.Parameters.AddWithValue("@ModelMappingID", objDB.ModelMappingID); objCmd.Parameters.AddWithValue("@HMR_Range", objDB.HMR_Range); objCmd.Parameters.AddWithValue("@FromDate", objDB.FromDate); objCmd.Parameters.AddWithValue("@ToDate", objDB.ToDate); objCmd.Parameters.AddWithValue("@MonthID", objDB.MonthID); objCmd.Parameters.AddWithValue("@YearID", objDB.YearID); objCmd.Parameters.AddWithValue("@Quarter", objDB.Quarter); objCmd.Parameters.AddWithValue("@Engine", objDB.Engine); objCmd.Parameters.AddWithValue("@IsEngine", objDB.IsEngine); objCmd.Parameters.AddWithValue("@ID", SqlDbType.Int); objCmd.Parameters["@ID"].Direction = ParameterDirection.Output; objCmd.Transaction = objTrans; objCmd.Connection = objTrans.Connection; objDataLayer.Command = objCmd; objDataLayer.ExecQuery(); ID = Convert.ToInt32(objCmd.Parameters["@ID"].Value); } catch (Exception ex) { throw ex; } return ID; }
public int SaveAcr(AcrUI objUI) { int ID = 0; bool flagTransation = true; AcrDB objDB = new AcrDB(); objDB.WCDOCNO = objUI.WCDOCNO; objDB.DLR_REF = objUI.DLR_REF; objDB.TRACTOR_NO = objUI.TRACTOR_NO; objDB.ENGINE_NO = objUI.ENGINE_NO; objDB.INS_DATE = objUI.INS_DATE; objDB.REP_DATE = objUI.REP_DATE; objDB.DEF_DATE = objUI.DEF_DATE; objDB.HMR = objUI.HMR; objDB.DLR_CO = objUI.DLR_CO; objDB.DEALER_NAME = objUI.DEALER_NAME; objDB.REG = objUI.REG; objDB.CR_DATE = objUI.CR_DATE; objDB.ITEM_CODE = objUI.ITEM_CODE; objDB.DESCRIPTION = objUI.DESCRIPTION; objDB.COST = objUI.COST; objDB.QUANTITY = objUI.QUANTITY; objDB.DEF = objUI.DEF; objDB.NDP = objUI.NDP; objDB.VALUE = objUI.VALUE; objDB.CVOICE = objUI.CVOICE; objDB.OUTLV = objUI.OUTLV; objDB.DT = objUI.DT; objDB.CUL_CODE = objUI.CUL_CODE; objDB.BLANK = objUI.BLANK; objDB.CR_AMOUNT = objUI.CR_AMOUNT; objDB.AUTH_AMOUNT = objUI.AUTH_AMOUNT; objDB.DIFF = objUI.DIFF; objDB.Production_Month = objUI.Production_Month; objDB.Production_Month_Year = objUI.Production_Month_Year; objDB.ModelMappingID = objUI.ModelMappingID; objDB.HMR_Range = objUI.HMR_Range; objDB.FromDate = objUI.FromDate; objDB.ToDate = objUI.ToDate; objDB.MonthID = objUI.MonthID; objDB.YearID = objUI.YearID; objDB.Quarter = objUI.Quarter; objDB.Engine = objUI.Engine; objDB.IsEngine = objUI.IsEngine; DataAccessLayer objDataAccess = new DataAccessLayer(); SqlTransaction objTrans = null; try { if (objTrans == null) { flagTransation = false; objDataAccess.GetConnection.Open(); SqlTransaction objTransaction = objDataAccess.GetConnection.BeginTransaction(); objTrans = objTransaction; } AcrManager objManager = new AcrManager(); ID = objManager.SaveAcr(objDB, objTrans); if (!flagTransation) objTrans.Commit(); } catch (Exception ex) { if (!flagTransation) objTrans.Rollback(); throw ex; } return ID; }