/// <summary> /// This method Saves Record into Database. /// </summary> /// <param name="objDept">Object containing Data values to be saved.</param> /// <returns>Boolean value True if Record is saved successfully /// otherwise returns False indicating Record is not saved.</returns> public static bool Save(Department objDept, User objCurUser) { int result = 0; UserCompany CurrentCompany = new UserCompany(); using (SqlConnection Conn = new SqlConnection(General.GetSQLConnectionString())) { string strSaveQry; if (objDept.IsNew) { strSaveQry = "INSERT INTO DEPTMAST(DBID, DEPTNAME, DESCRIPTION, ISACTIVE, " + " ST_DATE, MODIFY_DATE, CRBY, MODBY, MACHINENAME) " + "VALUES (@dbId, @DeptName, @Descr, @IsActive, " + " @STDate, @ModifyDate, @CrBy, @ModBy, @MachineName)"; } else { strSaveQry = "UPDATE DEPTMAST " + "SET DEPTNAME = @DeptName, DESCRIPTION = @Descr, ISACTIVE = @IsActive, " + "MODIFY_DATE = @ModifyDate, MODBY = @ModBy, MACHINENAME = @MachineName " + "WHERE DBID = @dbId"; } try { SqlCommand objCmd = Conn.CreateCommand(); objCmd.CommandType = CommandType.Text; objCmd.CommandText = strSaveQry; objCmd.Parameters.AddWithValue("@DeptName", objDept.DeptName); objCmd.Parameters.AddWithValue("@Descr", objDept.Description); objCmd.Parameters.AddWithValue("@IsActive", objDept.IsActive); if (objDept.IsNew) { objCmd.Parameters.AddWithValue("@StDate", DateTime.Now); objCmd.Parameters.AddWithValue("@CrBy", objCurUser.LoginName); objDept.DBID = General.GenerateDBID(Conn, "DEPTMAST"); } objCmd.Parameters.AddWithValue("@ModifyDate", DateTime.Now); objCmd.Parameters.AddWithValue("@ModBy", objCurUser.LoginName); objCmd.Parameters.AddWithValue("@MachineName", General.GetMachineName()); objCmd.Parameters.AddWithValue("@dbID", objDept.DBID); if (Conn.State != ConnectionState.Open) { Conn.Open(); } result = objCmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } } return(result > 0); }
/// <summary> /// This method Saves Record into Database. /// </summary> /// <param name="objDriver">Object containing Data values to be saved.</param> /// <returns>Boolean value True if Record is saved successfully /// otherwise returns False indicating Record is not saved.</returns> public static bool Save(Driver objDriver, User objUser) { int result = 0; UserCompany CurrentCompany = new UserCompany(); using (SqlConnection Conn = new SqlConnection(General.GetSQLConnectionString())) { string strSaveQry; if (objDriver.IsNew) { strSaveQry = "INSERT INTO DRIVERMASTER(DBID, NAME, LICENSENO, ISACTIVE, " + " ST_DATE, MODIFY_DATE, CRBY, MODBY, MACHINENAME) " + "VALUES (@dbId, @Name, @LicenseNo, @IsActive, " + " @STDate, @ModifyDate, @CrBy, @ModBy, @MachineName)"; } else { strSaveQry = "UPDATE DRIVERMASTER " + "SET NAME = @Name, LICENSENO = @LicenseNo, ISACTIVE = @IsActive, " + "MODIFY_DATE = @ModifyDate, MODBY = @ModBy, MACHINENAME = @MachineName " + "WHERE DBID = @dbId"; } try { SqlCommand objCmd = Conn.CreateCommand(); objCmd.CommandType = CommandType.Text; objCmd.CommandText = strSaveQry; objCmd.Parameters.AddWithValue("@Name", objDriver.Name); objCmd.Parameters.AddWithValue("@LicenseNo", objDriver.LicenceNo); objCmd.Parameters.AddWithValue("@IsActive", objDriver.IsActive); if (objDriver.IsNew) { objCmd.Parameters.AddWithValue("@StDate", DateTime.Now); objCmd.Parameters.AddWithValue("@CrBy", objUser.LoginName); objDriver.DBID = General.GenerateDBID(Conn, "DRIVERMASTER"); } objCmd.Parameters.AddWithValue("@ModifyDate", DateTime.Now); objCmd.Parameters.AddWithValue("@ModBy", objUser.LoginName); objCmd.Parameters.AddWithValue("@MachineName", General.GetMachineName()); objCmd.Parameters.AddWithValue("@dbID", objDriver.DBID); if (Conn.State != ConnectionState.Open) { Conn.Open(); } result = objCmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } } return(result > 0); }
/// <summary> /// This method Saves Record into Database. /// </summary> /// <param name="objDept">Object containing Data values to be saved.</param> /// <returns>Boolean value True if Record is saved successfully /// otherwise returns False indicating Record is not saved.</returns> public static bool Save(City objCity, User objUser) { int result = 0; UserCompany CurrentCompany = new UserCompany(); using (SqlConnection Conn = new SqlConnection(General.GetSQLConnectionString())) { string strSaveQry; if (objCity.IsNew) { strSaveQry = "INSERT INTO CITYMASTER(DBID, CITY, " + " ST_DATE, MODIFY_DATE, CRBY, MODBY, MACHINENAME) " + "VALUES (@dbId, @City, " + " @STDate, @ModifyDate, @CrBy, @ModBy, @MachineName)"; } else { strSaveQry = "UPDATE CITYMASTER " + "SET CITY = @CITY, MODIFY_DATE = @ModifyDate, " + "MODBY = @ModBy, MACHINENAME = @MachineName " + "WHERE DBID = @dbId"; } try { SqlCommand objCmd = Conn.CreateCommand(); objCmd.CommandType = CommandType.Text; objCmd.CommandText = strSaveQry; objCmd.Parameters.AddWithValue("@CITY", objCity.mCity); if (objCity.IsNew) { objCmd.Parameters.AddWithValue("@StDate", DateTime.Now); objCmd.Parameters.AddWithValue("@CrBy", objUser.LoginName); objCity.DBID = General.GenerateDBID(Conn, "CITYMASTER"); } objCmd.Parameters.AddWithValue("@ModifyDate", DateTime.Now); objCmd.Parameters.AddWithValue("@ModBy", objUser.LoginName); objCmd.Parameters.AddWithValue("@MachineName", General.GetMachineName()); objCmd.Parameters.AddWithValue("@dbID", objCity.DBID); if (Conn.State != ConnectionState.Open) { Conn.Open(); } result = objCmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } } return(result > 0); }
/// <summary> /// This method Saves Record into Database. /// </summary> /// <param name="objVisitor">Object containing Data values to be saved.</param> /// <returns>Boolean value True if Record is saved successfully /// otherwise returns False indicating Record is not saved.</returns> public static bool Save(Visitor objVisitor, User objUser) { int result = 0; UserCompany CurrentCompany = new UserCompany(); using (SqlConnection Conn = new SqlConnection(General.GetSQLConnectionString())) { string strSaveQry; if (objVisitor.IsNew) { strSaveQry = "INSERT INTO VISITORMASTER(DBID, VISITORREGNO, NAME, COMPANY, " + " ADDRESS, CONTACTNO, IDPROOFTYPE, IDPROOFNO, " + " ST_DATE, MODIFY_DATE, CRBY, MODBY, MACHINENAME) " + " VALUES (@dbId, @VisitorRegNo, @Name, @Company, " + " @Address, @ContactNo, @IdProofType, @IdProofNo, " + " @STDate, @ModifyDate, @CrBy, @ModBy, @MachineName)"; } else { strSaveQry = "UPDATE VISITORMASTER " + " SET VISITORREGNO = @VisitorRegNo, NAME = @Name, COMPANY = @Company, ADDRESS = @Address, " + " CONTACTNO = @ContactNo, IDPROOFTYPE = @IdProofType, IDPROOFNO = @IdProofNo, " + " MODIFY_DATE = @ModifyDate, MODBY = @ModBy, MACHINENAME = @MachineName " + " WHERE DBID = @dbId"; } try { SqlCommand objCmd = Conn.CreateCommand(); objCmd.CommandType = CommandType.Text; objCmd.CommandText = strSaveQry; objCmd.Parameters.AddWithValue("@Name", objVisitor.VName); objCmd.Parameters.AddWithValue("@Company", objVisitor.Company); objCmd.Parameters.AddWithValue("@Address", objVisitor.Address); objCmd.Parameters.AddWithValue("@ContactNo", objVisitor.MobileNo); objCmd.Parameters.AddWithValue("@IDProofType", objVisitor.IDProofType); objCmd.Parameters.AddWithValue("@IDProofNo", objVisitor.IDProofNo); if (objVisitor.IsNew) { objCmd.Parameters.AddWithValue("@StDate", DateTime.Now); objCmd.Parameters.AddWithValue("@CrBy", objUser.LoginName); //objVisitor.DBID = General.GenerateDBID(Conn, "VISITORMASTER"); objVisitor.DBID = General.GenerateDBID("SEQVISITORID", Conn); objVisitor.RegNo = objVisitor.DBID; } objCmd.Parameters.AddWithValue("@ModifyDate", DateTime.Now); objCmd.Parameters.AddWithValue("@ModBy", objUser.LoginName); objCmd.Parameters.AddWithValue("@MachineName", General.GetMachineName()); objCmd.Parameters.AddWithValue("@dbID", objVisitor.DBID); objCmd.Parameters.AddWithValue("@VisitorRegNo", objVisitor.RegNo); if (Conn.State != ConnectionState.Open) { Conn.Open(); } result = objCmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } } return(result > 0); }
/// <summary> /// This method Saves Record into Database. /// </summary> /// <param name="objAppoint">Object containing Data values to be saved.</param> /// <returns>Boolean value True if Record is saved successfully /// otherwise returns False indicating Record is not saved.</returns> public static bool Save(Appointment objAppoint, User currentUser) { int result = 0; string mDate; DateTime dt = Convert.ToDateTime(DateTime.Now.ToShortDateString()); string mdt; long mNo; long mDbid; UserCompany CurrentCompany = new UserCompany(); using (SqlConnection Conn = new SqlConnection(General.GetSQLConnectionString())) { string strSaveQry; if (objAppoint.IsNew) { strSaveQry = "INSERT INTO APPOINTMENTMASTER(DBID,ENTRYNO,ENTRYDATE,APPOINTMENTNO," + " APPOINTMENTDATE,SCHEDULEDTIME, NAME, COMPANY, CONTACTNO, EMPLOYEEID, " + " ST_DATE, MODIFY_DATE, CRBY, MODBY, MACHINENAME, VISITORID, APMTCLOSE) " + "VALUES (@dbId, @entryNo, @entryDate, @appointmentNo, @appointmentDate," + " @scheduleTime,@Name,@Company, @ContactNo, @employeeID, " + " @STDate, @ModifyDate, @CrBy, @ModBy, @MachineName, @VisitorID, @ApmtClose)"; } else { strSaveQry = "UPDATE APPOINTMENTMASTER " + "SET ENTRYNO =@entryNo, ENTRYDATE =@entryDate , APPOINTMENTNO =@appointmentNo , " + " APPOINTMENTDATE = @appointmentDate, SCHEDULEDTIME = @scheduleTime, NAME = @Name, " + " COMPANY = @Company, CONTACTNO = @ContactNo, EMPLOYEEID = @employeeID, " + " MODIFY_DATE = @ModifyDate, MODBY = @ModBy, MACHINENAME = @MachineName, " + " VISITORID = @VisitorID, APMTCLOSE = @ApmtClose " + " WHERE DBID = @dbId"; } try { SqlCommand objCmd = Conn.CreateCommand(); objCmd.CommandType = CommandType.Text; objCmd.CommandText = strSaveQry; objCmd.Parameters.AddWithValue("@AppointmentDate", objAppoint.AppointmentDate); objCmd.Parameters.AddWithValue("@ScheduleTime", objAppoint.ScheduleTime); objCmd.Parameters.AddWithValue("@VisitorID", objAppoint.VisitorID); objCmd.Parameters.AddWithValue("@Name", objAppoint.Name); objCmd.Parameters.AddWithValue("@Company", objAppoint.Company); objCmd.Parameters.AddWithValue("@ContactNo", objAppoint.ContactNo); objCmd.Parameters.AddWithValue("@EmployeeID", objAppoint.EmployeeID); if (objAppoint.IsNew) { objCmd.Parameters.AddWithValue("@StDate", DateTime.Now); objCmd.Parameters.AddWithValue("@CrBy", currentUser.LoginName); objAppoint.EntryDate = dt; //objAppoint.DBID = General.GenerateDBID(Conn, "APPOINTMENTMASTER"); objAppoint.DBID = General.GenerateDBID("SEQAPPOINTMENTID", Conn); objAppoint.EntryNo = objAppoint.DBID; mDbid = objAppoint.DBID; mNo = 4 - (Convert.ToString(mDbid).Trim().Length); mdt = ""; if (mNo == 3) { mdt = "000" + "" + mDbid; } if (mNo == 2) { mdt = "00" + "" + mDbid; } if (mNo == 1) { mdt = "0" + "" + mDbid; } mDate = String.Format("{0:yyMMdd}", dt) + "" + mdt; objAppoint.AppointmentNo = mDate; } objCmd.Parameters.AddWithValue("@ModifyDate", DateTime.Now); objCmd.Parameters.AddWithValue("@ModBy", currentUser.LoginName); objCmd.Parameters.AddWithValue("@MachineName", General.GetMachineName()); objCmd.Parameters.AddWithValue("@dbID", objAppoint.DBID); objCmd.Parameters.AddWithValue("@EntryDate", objAppoint.EntryDate); objCmd.Parameters.AddWithValue("@entryNo", objAppoint.EntryNo); objCmd.Parameters.AddWithValue("@AppointmentNo", objAppoint.AppointmentNo); objCmd.Parameters.AddWithValue("@ApmtClose", objAppoint.ApmtClose); if (Conn.State != ConnectionState.Open) { Conn.Open(); } result = objCmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } } return(result > 0); }
/// <summary> /// This method Saves Record into Database. /// </summary> /// <param name="objDept">Object containing Data values to be saved.</param> /// <returns>Boolean value True if Record is saved successfully /// otherwise returns False indicating Record is not saved.</returns> public static bool Save(VisitorGatePass objVisitorGP, User objCurUser) { int result = 0; //string tmpStr = ""; DateTime dt = Convert.ToDateTime(DateTime.Now.ToShortDateString()); UserCompany CurrentCompany = new UserCompany(); using (SqlConnection Conn = new SqlConnection(General.GetSQLConnectionString())) { string strSaveQry; if (objVisitorGP.IsNew) { strSaveQry = "INSERT INTO VISITORGATEPASS(dbid, gatePassNo, gateDate, " + " visitorID, Name, address, contactNo, vehicleNo, depositedMaterial, " + " carryMaterial, NoOfPersons, company, empID, toMeet, purpose, " + " timeIn, timeOut, appointmentNo, empMobile, exPersons, " + " ST_DATE, MODIFY_DATE, CRBY, MODBY, MACHINENAME, VIMAGE) " + " VALUES (@dbid, @gatePassNo, @gateDate, @visitorID, @visitorName, " + " @address, @contactNo, @vehicleNo, @depositMaterial, " + " @carryMaterial, @NoOfPerson, @companyName, @empID, @toMeet, @purpose, " + " @timeIn, @timeOut, @appointmentNo, @empMobile, @exPersons, " + " @STDate, @ModifyDate, @CrBy, @ModBy, @MachineName, @VImage)"; } else { strSaveQry = "UPDATE VISITORGATEPASS " + " SET gatePassNo = @GatePassNo, gateDate = @GateDate, visitorID = @visitorID, " + " Name = @visitorName, address = @address, contactNo = @contactNo, " + " vehicleNo = @vehicleNo, depositedMaterial = @depositMaterial, " + " carryMaterial = @carryMaterial, NoOfPersons = @NoOfPerson, company = @companyName, " + " empID = @empID, toMeet = @toMeet, purpose = @purpose, timeIn = @timeIn, " + " timeOut = @timeOut, appointmentNo = @appointmentNo, " + " empMobile = @empMobile, exPersons = @exPersons " + " WHERE DBID = @dbId"; } try { SqlCommand objCmd = Conn.CreateCommand(); objCmd.CommandType = CommandType.Text; objCmd.CommandText = strSaveQry; objCmd.Parameters.AddWithValue("@gateDate", objVisitorGP.GateDate); objCmd.Parameters.AddWithValue("@visitorID", objVisitorGP.VisitorID); objCmd.Parameters.AddWithValue("@visitorName", objVisitorGP.VisitorName); objCmd.Parameters.AddWithValue("@address", objVisitorGP.Address); objCmd.Parameters.AddWithValue("@contactNo", objVisitorGP.ContactNo); objCmd.Parameters.AddWithValue("@vehicleNo", objVisitorGP.VehicleNo); objCmd.Parameters.AddWithValue("@depositMaterial", objVisitorGP.DepositMaterial); objCmd.Parameters.AddWithValue("@carryMaterial", objVisitorGP.CarryMaterial); objCmd.Parameters.AddWithValue("@NoOfPerson", objVisitorGP.NoOfPersons); objCmd.Parameters.AddWithValue("@companyName", objVisitorGP.CompanyName); objCmd.Parameters.AddWithValue("@empID", objVisitorGP.EmployeeID); objCmd.Parameters.AddWithValue("@toMeet", objVisitorGP.ToMeet); objCmd.Parameters.AddWithValue("@purpose", objVisitorGP.Purpose); objCmd.Parameters.AddWithValue("@timeIn", objVisitorGP.TimeIn); if (objVisitorGP.TimeOut == DateTime.MinValue) { objCmd.Parameters.AddWithValue("@timeOut", DBNull.Value); } else { objCmd.Parameters.AddWithValue("@timeOut", objVisitorGP.TimeOut); } //objCmd.Parameters.AddWithValue("@imgFileName", objVisitorGP.ImgFileName); objCmd.Parameters.AddWithValue("@appointmentNo", objVisitorGP.AppointmentNo); objCmd.Parameters.AddWithValue("@empMobile", objVisitorGP.EmpMobile); objCmd.Parameters.AddWithValue("@exPersons", objVisitorGP.ExtraPersons); if (objVisitorGP.IsNew) { objCmd.Parameters.AddWithValue("@StDate", DateTime.Now); objCmd.Parameters.AddWithValue("@CrBy", objCurUser.LoginName); objCmd.Parameters.AddWithValue("@VImage", objVisitorGP.VisitorImage); objVisitorGP.DBID = General.GenerateDBID(Conn, "VISITORGATEPASS"); objVisitorGP.GatePassNo = string.Format("{0:yyMMdd}", dt) + Convert.ToString(objVisitorGP.DBID).PadLeft(4, Convert.ToChar(48)); } objCmd.Parameters.AddWithValue("@ModifyDate", DateTime.Now); objCmd.Parameters.AddWithValue("@ModBy", objCurUser.LoginName); objCmd.Parameters.AddWithValue("@MachineName", General.GetMachineName()); objCmd.Parameters.AddWithValue("@gatePassNo", objVisitorGP.GatePassNo); objCmd.Parameters.AddWithValue("@dbID", objVisitorGP.DBID); if (Conn.State != ConnectionState.Open) { Conn.Open(); } result = objCmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } } return(result > 0); }
/// <summary> /// This method Saves Record into Database. /// </summary> /// <param name="objDCItem">Object containing Data values to be saved.</param> /// <returns>Boolean value True if Record is saved successfully /// otherwise returns False indicating Record is not saved.</returns> public static bool Save(ReturnableDCItem objDCItem, User currentUser) { int result = 0; UserCompany CurrentCompany = new UserCompany(); using (SqlConnection Conn = new SqlConnection(General.GetSQLConnectionString())) { string strSaveQry; if (objDCItem.IsNew) { strSaveQry = "INSERT INTO RETURNABLEDCDETAIL(DBID, ENTRYNO, ENTRYDATE, ENTRYTYPE, " + " DCNO, DCDATE, ITEMCODE, ITEMDESCR, QTY, QTY2, UNIT, REMARK, MASTERDBID, " + " ST_DATE, MODIFY_DATE, CRBY, MODBY, MACHINENAME) " + " VALUES (@dbId, @EntryNo, @EntryDate, @EntryType, @DCNo, @DCDate, " + " @ItemCode, @ItemDescr, @Qty, @Qty2, @Unit, @Remark, @MasterDBID, " + " @STDate, @ModifyDate, @CrBy, @ModBy, @MachineName)"; } else { strSaveQry = "UPDATE RETURNABLEDCDETAIL " + " SET ENTRYNO = @EntryNo, ENTRYDATE = @EntryDate, ENTRYTYPE = @EntryType, " + " DCNO = @DCNo, DCDATE = @DCDate, ITEMCODE = @ItemCode, ITEMDESCR = @ItemDescr" + " Qty = @QTY, QTY2 = @Qty2, UNIT = @Unit, REMARK = @Remark, " + " MASTERDBID = @MasterDBID, MODIFY_DATE = @ModifyDate, " + " MODBY = @ModBy, MACHINENAME = @MachineName " + " WHERE DBID = @dbId"; } try { SqlCommand objCmd = Conn.CreateCommand(); objCmd.CommandType = CommandType.Text; objCmd.CommandText = strSaveQry; objCmd.Parameters.AddWithValue("@EntryNo", objDCItem.EntryNo); objCmd.Parameters.AddWithValue("@EntryDate", objDCItem.EntryDate); objCmd.Parameters.AddWithValue("@EntryType", objDCItem.EntryType); objCmd.Parameters.AddWithValue("@DCNo", objDCItem.DCNo); objCmd.Parameters.AddWithValue("@DCDate", objDCItem.DCDate); objCmd.Parameters.AddWithValue("@ItemCode", objDCItem.ItemCode); objCmd.Parameters.AddWithValue("@ItemDescr", objDCItem.ItemDescr); objCmd.Parameters.AddWithValue("@Qty", objDCItem.Qty); objCmd.Parameters.AddWithValue("@Qty2", objDCItem.Qty2); objCmd.Parameters.AddWithValue("@Unit", objDCItem.UnitName); objCmd.Parameters.AddWithValue("@Remark", objDCItem.Remark); if (objDCItem.IsNew) { objCmd.Parameters.AddWithValue("@StDate", DateTime.Now); objCmd.Parameters.AddWithValue("@CrBy", currentUser.LoginName); //objDCItem.DBID = General.GenerateDBID(Conn, "RETURNABLEDCDETAIL"); objDCItem.DBID = General.GenerateDBID("SEQDCITEMID", Conn); } objCmd.Parameters.AddWithValue("@ModifyDate", DateTime.Now); objCmd.Parameters.AddWithValue("@ModBy", currentUser.LoginName); objCmd.Parameters.AddWithValue("@MachineName", General.GetMachineName()); objCmd.Parameters.AddWithValue("@dbID", objDCItem.DBID); objCmd.Parameters.AddWithValue("@MasterDBID", objDCItem.MasterDBID); if (Conn.State != ConnectionState.Open) { Conn.Open(); } result = objCmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } } return(result > 0); }
/// <summary> /// This method Saves Record into Database. /// </summary> /// <param name="objRetDC">Object containing Data values to be saved.</param> /// <returns>Boolean value True if Record is saved successfully /// otherwise returns False indicating Record is not saved.</returns> public static bool Save(ReturnableDC objRetDC, User currentUser) { int result = 0; UserCompany CurrentCompany = new UserCompany(); using (SqlConnection Conn = new SqlConnection(General.GetSQLConnectionString())) { string strSaveQry; if (objRetDC.IsNew) { strSaveQry = "INSERT INTO RETURNABLEDC(DBID, ENTRYNO, ENTRYDATE, ENTRYTYPE, " + " PARTYNAME, VEHICLENO, DCNO, DCDATE, PLANT, VINDATE, VINTIME, VOUTDATE, " + " VOUTTIME, ST_DATE, MODIFY_DATE, CRBY, MODBY, MACHINENAME) " + " VALUES (@dbId, @EntryNo, @EntryDate, @EntryType, @PartyName, @VehicleNo, " + " @DCNo, @DCDate, @Plant, @VinDate, @VinTime, @VOutDate, @VoutTime, " + " @STDate, @ModifyDate, @CrBy, @ModBy, @MachineName)"; } else { strSaveQry = "UPDATE RETURNABLEDC " + " SET ENTRYNO = @EntryNo, ENTRYDATE = @EntryDate, ENTRYTYPE = @EntryType, " + " PARTYNAME = @PartyName, VEHICLENO = @VehicleNo, DCNO = @DCNo, " + " DCDATE = @DCDate, PLANT = @Plant, VINDATE = @VInDate, VINTIME = @VInTime, " + " VOUTDATE = @VOutDate, VOUTTIME = @VOutTime, MODIFY_DATE = @ModifyDate, " + " MODBY = @ModBy, MACHINENAME = @MachineName " + " WHERE DBID = @dbId"; } try { SqlCommand objCmd = Conn.CreateCommand(); objCmd.CommandType = CommandType.Text; objCmd.CommandText = strSaveQry; objCmd.Parameters.AddWithValue("@EntryDate", objRetDC.EntryDate); objCmd.Parameters.AddWithValue("@EntryType", objRetDC.EntryType); objCmd.Parameters.AddWithValue("@PartyName", objRetDC.PartyName); if (objRetDC.VehicleNo == string.Empty) { objCmd.Parameters.AddWithValue("@VehicleNo", DBNull.Value); } else { objCmd.Parameters.AddWithValue("@VehicleNo", objRetDC.VehicleNo); } objCmd.Parameters.AddWithValue("@DCNo", objRetDC.DCNo); objCmd.Parameters.AddWithValue("@DCDate", objRetDC.DCDate); objCmd.Parameters.AddWithValue("@Plant", objRetDC.PlantName); if (objRetDC.VInDate == DateTime.MinValue) { objCmd.Parameters.AddWithValue("@VInDate", DBNull.Value); } else { objCmd.Parameters.AddWithValue("@VInDate", objRetDC.VInDate); } if (objRetDC.VInTime == DateTime.MinValue) { objCmd.Parameters.AddWithValue("@VInTime", DBNull.Value); } else { objCmd.Parameters.AddWithValue("@VInTime", objRetDC.VInTime); } if (objRetDC.VOutDate == DateTime.MinValue) { objCmd.Parameters.AddWithValue("@VOutDate", DBNull.Value); } else { objCmd.Parameters.AddWithValue("@VOutDate", objRetDC.VOutDate); } if (objRetDC.VOutTime == DateTime.MinValue) { objCmd.Parameters.AddWithValue("@VOutTime", DBNull.Value); } else { objCmd.Parameters.AddWithValue("@VOutTime", objRetDC.VOutTime); } if (objRetDC.IsNew) { objCmd.Parameters.AddWithValue("@StDate", DateTime.Now); objCmd.Parameters.AddWithValue("@CrBy", currentUser.LoginName); //objRetDC.DBID = General.GenerateDBID(Conn, "RETURNABLEDC"); objRetDC.DBID = General.GenerateDBID("SEQDCID", Conn); objRetDC.EntryNo = objRetDC.DBID; } objCmd.Parameters.AddWithValue("@ModifyDate", DateTime.Now); objCmd.Parameters.AddWithValue("@ModBy", currentUser.LoginName); objCmd.Parameters.AddWithValue("@MachineName", General.GetMachineName()); objCmd.Parameters.AddWithValue("@dbID", objRetDC.DBID); objCmd.Parameters.AddWithValue("@EntryNo", objRetDC.EntryNo); if (Conn.State != ConnectionState.Open) { Conn.Open(); } result = objCmd.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } } return(result > 0); }
/// <summary> /// This method Saves Record into Database. /// </summary> /// <param name="objDept">Object containing Data values to be saved.</param> /// <returns>Boolean value True if Record is saved successfully /// otherwise returns False indicating Record is not saved.</returns> public static bool Save(VehInOut objVehInOut, User objUser) { int result = 0; string strSaveQry; UserCompany CurrentCompany = new UserCompany(); using (SqlConnection Conn = new SqlConnection(General.GetSQLConnectionString())) { //string strSaveQry; if (objVehInOut.IsNew) { //objCmd.CommandText = "INSERT INTO VEHINOUTDETAIL(DBID,ENTRYNO,ENTRYDATE,TYPE," + // " INOUT,INDATE,INTIME,OUTDATE,OUTTIME,VEHNO,DRIVERNAME,CITYNAME," + // " VENDORIN,VENDOROUT,PLANT,ININVCNT,OUTINVCNT,INCARRYMATERIAL, " + // " OUTCARRYMATERIAL,PUCFLG,PUCNO,RCBOOKFLG,RCBOOKNO,FINANCE, " + // " FITNESSFLG,FITNESSNO,DRLICFLG,DRLICNO,PERSONSWITHVEH, " + // " ST_DATE, MODIFY_DATE, CR_BY, MOD_BY, MACHINENAME, INREADING, OUTREADING) " + // " VALUES (" + objVehInOut.Dbid + "," + // " " + objVehInOut.EntryNo + "," + // " '" + objVehInOut.EntryDate.ToString("dd-MMM-yy") + "'," + // " " + objVehInOut.Type + "," + // " " + objVehInOut.InOut + "," + // " '" + objVehInOut.InDate.ToString("dd-MMM-yy") + "'," + // " '" + objVehInOut.InTime.ToShortTimeString() + "'," + // " '" + objVehInOut.OutDate.ToString("dd-MMM-yy") + "'," + // " '" + objVehInOut.OutTime.ToShortTimeString() + "'," + // " '" + objVehInOut.VehNo + "'," + // " '" + objVehInOut.DriverName + "'," + // " '" + objVehInOut.CityName + "'," + // " '" + objVehInOut.VendorIn + "'," + // " '" + objVehInOut.VendorOut + "'," + // " '" + objVehInOut.Plant + "'," + // " " + objVehInOut.InInvCnt + "," + // " " + objVehInOut.OutInvCnt + "," + // " '" + objVehInOut.InCarryMaterial + "'," + // " '" + objVehInOut.OutCarryMaterial + "'," + // " '" + objVehInOut.PUCFlg + "'," + // " '" + objVehInOut.PUCNo + "'," + // " '" + objVehInOut.RCBookFlg + "'," + // " '" + objVehInOut.RCBookNo + "'," + // " '" + objVehInOut.Finance + "'," + // " '" + objVehInOut.FitnessFlg + "'," + // " '" + objVehInOut.FitnessNo + "'," + // " '" + objVehInOut.DrLicFlg + "'," + // " '" + objVehInOut.DrLicNo + "'," + // " " + objVehInOut.PersonsWithVeh + "," + // " '" + DateTime.Now.ToString("dd-MMM-yy") + "'," + // " '" + DateTime.Now.ToString("dd-MMM-yy") + "'," + // " '" + CurrentCompany.m_UserName + "'," + // " '" + CurrentCompany.m_UserName + "'," + // " '" + System.Environment.MachineName + "'," + objVehInOut.InReading + "," + objVehInOut.OutReading + ")"; strSaveQry = "INSERT INTO VEHINOUTDETAIL(DBID, ENTRYNO, ENTRYDATE, TYPE, " + " INOUT, INDATE, INTIME, OUTDATE, OUTTIME, VEHNO, DRIVERNAME, CITYNAME," + " VENDORIN, VENDOROUT, PLANT, ININVCNT, OUTINVCNT, INCARRYMATERIAL, " + " OUTCARRYMATERIAL, PUCFLG, PUCNO, RCBOOKFLG, RCBOOKNO, FINANCE, " + " FITNESSFLG, FITNESSNO, DRLICFLG, DRLICNO, PERSONSWITHVEH, " + " ST_DATE, MODIFY_DATE, CR_BY, MOD_BY, MACHINENAME, INREADING, OUTREADING) " + " VALUES (@DBID, @ENTRYNO, @ENTRYDATE, @TYPE, " + " @INOUT, @INDATE, @INTIME, @OUTDATE, @OUTTIME, @VEHNO, @DRIVERNAME, @CITYNAME, " + " @VENDORIN, @VENDOROUT, @PLANT, @ININVCNT, @OUTINVCNT, @INCARRYMATERIAL," + " @OUTCARRYMATERIAL, @PUCFLG, @PUCNO, @RCBOOKFLG, @RCBOOKNO, @FINANCE, " + " @FITNESSFLG, @FITNESSNO, @DRLICFLG, @DRLICNO, @PERSONSWITHVEH, " + " @STDATE, @ModifyDate, @CrBy, @ModBy, @MachineName, @INREADING, @OUTREADING)"; } else { //objCmd.CommandText = "UPDATE VEHINOUTDETAIL " + // "SET ENTRYNO =" + objVehInOut.EntryNo + "," + // " ENTRYDATE ='" + objVehInOut.EntryDate.ToString("dd-MMM-yy") + "'," + // " TYPE =" + objVehInOut.Type + "," + // " INOUT = " + objVehInOut.InOut + "," + // " INDATE ='" + objVehInOut.InDate.ToString("dd-MMM-yy") + "'," + // " INTIME ='" + objVehInOut.InTime.ToShortTimeString() + "'," + // " OUTDATE ='" + objVehInOut.OutDate.ToString("dd-MMM-yy") + "'," + // " OUTTIME ='" + objVehInOut.OutTime.ToShortTimeString() + "'," + // " VEHNO ='" + objVehInOut.VehNo + "'," + // " DRIVERNAME = '" + objVehInOut.DriverName + "'," + // " CITYNAME = '" + objVehInOut.CityName + "'," + // " VENDORIN = '" + objVehInOut.VendorIn + "'," + // " VENDOROUT = '" + objVehInOut.VendorIn + "'," + // " PLANT ='" + objVehInOut.Plant + "'," + // " ININVCNT = " + objVehInOut.InInvCnt + "," + // " OUTINVCNT = " + objVehInOut.OutInvCnt + "," + // " INCARRYMATERIAL = '" + objVehInOut.InCarryMaterial + "'," + // " OUTCARRYMATERIAL = '" + objVehInOut.OutCarryMaterial + "'," + // " PUCFLG = '" + objVehInOut.PUCFlg + "'," + // " PUCNO ='" + objVehInOut.PUCNo + "'," + // " RCBOOKFLG = '" + objVehInOut.RCBookFlg + "'," + // " RCBOOKNO = '" + objVehInOut.RCBookNo + "'," + // " FINANCE = '" + objVehInOut.Finance + "'," + // " FITNESSFLG ='" + objVehInOut.FitnessFlg + "'," + // " FITNESSNO = '" + objVehInOut.FitnessNo + "'," + // " DRLICFLG = '" + objVehInOut.DrLicFlg + "'," + // " DRLICNO = '" + objVehInOut.DrLicNo + "'," + // " PERSONSWITHVEH = " + objVehInOut.PersonsWithVeh + "," + // " MODIFY_DATE = '" + DateTime.Now.ToString("dd-MMM-yy") + "'," + // " MOD_BY = '" + CurrentCompany.m_UserName + "'," + // " MACHINENAME ='" + System.Environment.MachineName + "'," + // " INREADING = " + objVehInOut.InReading + ", " + // " OUTREADING = " + objVehInOut.OutReading + // " WHERE DBID = " + objVehInOut.Dbid + ""; strSaveQry = "UPDATE VEHINOUTDETAIL " + "SET ENTRYNO = @ENTRYNO , ENTRYDATE = @ENTRYDATE, TYPE = @TYPE, INOUT = @INOUT, " + " INDATE = @INDATE , INTIME = @INTIME , OUTDATE = @OUTDATE , OUTTIME = @OUTTIME , " + " VEHNO = @VEHNO , DRIVERNAME = @DRIVERNAME , CITYNAME = @CITYNAME , VENDORIN = @VENDORIN , " + " VENDOROUT = @VENDOROUT , PLANT = @PLANT, ININVCNT = @ININVCNT, OUTINVCNT = @OUTINVCNT , " + " INCARRYMATERIAL = @INCARRYMATERIAL, OUTCARRYMATERIAL = @OUTCARRYMATERIAL , PUCFLG = @PUCFLG , " + " PUCNO = @PUCNO , RCBOOKFLG = @RCBOOKFLG , RCBOOKNO = @RCBOOKNO, FINANCE = @FINANCE, " + " FITNESSFLG = @FITNESSFLG, FITNESSNO = @FITNESSNO , DRLICFLG = @DRLICFLG , DRLICNO =@DRLICNO , " + " PERSONSWITHVEH = @PERSONSWITHVEH , MODIFY_DATE = @MODIFYDATE, MOD_BY = @MODBY, " + " MACHINENAME = @MACHINENAME, INREADING = @INREADING, OUTREADING = @OUTREADING " + " WHERE DBID = @DBID"; } try { SqlCommand objCmd = Conn.CreateCommand(); objCmd.CommandType = CommandType.Text; objCmd.CommandText = strSaveQry; //objCmd.Parameters.AddWithValue("@ENTRYNO", objVehInOut.EntryNo); //objCmd.Parameters.AddWithValue("@ENTRYDATE", objVehInOut.EntryDate.ToShortDateString()); objCmd.Parameters.AddWithValue("@TYPE", objVehInOut.Type); objCmd.Parameters.AddWithValue("@INOUT", objVehInOut.InOut); if (objVehInOut.InDate != DateTime.MinValue) { objCmd.Parameters.AddWithValue("@INDATE", objVehInOut.InDate); } else { objCmd.Parameters.AddWithValue("@INDATE", DBNull.Value); } if (objVehInOut.InTime != DateTime.MinValue) { objCmd.Parameters.AddWithValue("@INTIME", objVehInOut.InTime); } else { objCmd.Parameters.AddWithValue("@INTIME", DBNull.Value); } if (objVehInOut.OutDate != DateTime.MinValue) { objCmd.Parameters.AddWithValue("@OUTDATE", objVehInOut.OutDate); } else { objCmd.Parameters.AddWithValue("@OUTDATE", DBNull.Value); } if (objVehInOut.OutTime != DateTime.MinValue) { objCmd.Parameters.AddWithValue("@OUTTIME", objVehInOut.OutTime); } else { objCmd.Parameters.AddWithValue("@OUTTIME", DBNull.Value); } objCmd.Parameters.AddWithValue("@VEHNO", objVehInOut.VehNo); objCmd.Parameters.AddWithValue("@DRIVERNAME", objVehInOut.DriverName); objCmd.Parameters.AddWithValue("@CITYNAME", objVehInOut.CityName); objCmd.Parameters.AddWithValue("@VENDORIN", objVehInOut.VendorIn); objCmd.Parameters.AddWithValue("@VENDOROUT", objVehInOut.VendorOut); objCmd.Parameters.AddWithValue("@PLANT", objVehInOut.Plant); objCmd.Parameters.AddWithValue("@ININVCNT", objVehInOut.InInvCnt); objCmd.Parameters.AddWithValue("@OUTINVCNT", objVehInOut.OutInvCnt); objCmd.Parameters.AddWithValue("@INCARRYMATERIAL", objVehInOut.InCarryMaterial); objCmd.Parameters.AddWithValue("@OUTCARRYMATERIAL", objVehInOut.OutCarryMaterial); objCmd.Parameters.AddWithValue("@PUCFLG", objVehInOut.PUCFlg); objCmd.Parameters.AddWithValue("@PUCNO", objVehInOut.PUCNo); objCmd.Parameters.AddWithValue("@RCBOOKFLG", objVehInOut.RCBookFlg); objCmd.Parameters.AddWithValue("@RCBOOKNO", objVehInOut.RCBookNo); objCmd.Parameters.AddWithValue("@FINANCE", objVehInOut.Finance); objCmd.Parameters.AddWithValue("@FITNESSFLG", objVehInOut.FitnessFlg); objCmd.Parameters.AddWithValue("@FITNESSNO", objVehInOut.FitnessNo); objCmd.Parameters.AddWithValue("@DRLICFLG", objVehInOut.DrLicFlg); objCmd.Parameters.AddWithValue("@DRLICNO", objVehInOut.DrLicNo); objCmd.Parameters.AddWithValue("@PERSONSWITHVEH", objVehInOut.PersonsWithVeh); if (objVehInOut.IsNew) { objVehInOut.EntryDate = DateTime.Now.Date; //objVehInOut.Dbid = General.GenerateDBID(Conn, "VEHINOUTDETAIL"); objVehInOut.Dbid = General.GenerateDBID("SEQVEHINOUTID", Conn); objVehInOut.EntryNo = objVehInOut.Dbid; objCmd.Parameters.AddWithValue("@STDATE", DateTime.Now); objCmd.Parameters.AddWithValue("@CRBY", objUser.LoginName); //CurrentCompany.m_UserName } objCmd.Parameters.AddWithValue("@DBID", objVehInOut.Dbid); objCmd.Parameters.AddWithValue("@ENTRYNO", objVehInOut.EntryNo); objCmd.Parameters.AddWithValue("@ENTRYDATE", objVehInOut.EntryDate); objCmd.Parameters.AddWithValue("@MODIFYDATE", DateTime.Now); objCmd.Parameters.AddWithValue("@MODBY", objUser.LoginName); //CurrentCompany.m_UserName objCmd.Parameters.AddWithValue("@MACHINENAME", General.GetMachineName()); objCmd.Parameters.AddWithValue("@INREADING", objVehInOut.InReading); objCmd.Parameters.AddWithValue("@OUTREADING", objVehInOut.OutReading); if (Conn.State != ConnectionState.Open) { Conn.Open(); } result = objCmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } finally { Conn.Close(); } Conn.Dispose(); } return(result > 0); }
/// <summary> /// This method Saves Record into Database. /// </summary> /// <param name="objDept">Object containing Data values to be saved.</param> /// <returns>Boolean value True if Record is saved successfully /// otherwise returns False indicating Record is not saved.</returns> public static bool Save(Vehicle objVehicle, User objUser) { int result = 0; UserCompany CurrentCompany = new UserCompany(); using (SqlConnection Conn = new SqlConnection(General.GetSQLConnectionString())) { string strSaveQry; if (objVehicle.IsNew) { strSaveQry = "INSERT INTO VEHICLEMASTER(DBID, VEHICLENO, VLICENSENO,PUCEXPIRY,ISACTIVE, " + " ST_DATE, MODIFY_DATE, CRBY, MODBY, MACHINENAME) " + "VALUES (@dbId, @VehicleNo, @VLicencseNo,@PUCExpiry, @IsActive, " + " @STDate, @ModifyDate, @CrBy, @ModBy, @MachineName)"; } else { strSaveQry = "UPDATE VEHICLEMASTER " + "SET VEHICLENO = @VehicleNo, VLICENSENO = @VLicencseNo,PUCEXPIRY = @PUCExpiry, ISACTIVE = @IsActive, " + "MODIFY_DATE = @ModifyDate, MODBY = @ModBy, MACHINENAME = @MachineName " + "WHERE DBID = @dbId"; } try { SqlCommand objCmd = Conn.CreateCommand(); objCmd.CommandType = CommandType.Text; objCmd.CommandText = strSaveQry; objCmd.Parameters.AddWithValue("@VehicleNo", objVehicle.VehicleNo); objCmd.Parameters.AddWithValue("@VLicencseNo", objVehicle.VLicencseNo); if (objVehicle.PUCExpiry != DateTime.MinValue) { objCmd.Parameters.AddWithValue("@PUCExpiry", objVehicle.PUCExpiry); } else { objCmd.Parameters.AddWithValue("@PUCExpiry", DBNull.Value); } objCmd.Parameters.AddWithValue("@IsActive", objVehicle.IsActive); if (objVehicle.IsNew) { objCmd.Parameters.AddWithValue("@StDate", DateTime.Now); objCmd.Parameters.AddWithValue("@CrBy", objUser.LoginName); objVehicle.Dbid = General.GenerateDBID(Conn, "VEHICLEMASTER"); } objCmd.Parameters.AddWithValue("@ModifyDate", DateTime.Now); objCmd.Parameters.AddWithValue("@ModBy", objUser.LoginName); objCmd.Parameters.AddWithValue("@MachineName", General.GetMachineName()); objCmd.Parameters.AddWithValue("@dbID", objVehicle.Dbid); if (Conn.State != ConnectionState.Open) { Conn.Open(); } result = objCmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } } return(result > 0); }
/// <summary> /// This method Saves Record into Database. /// </summary> /// <param name="objEmp">Object containing Data values to be saved.</param> /// <returns>Boolean value True if Record is saved successfully /// otherwise returns False indicating Record is not saved.</returns> public static bool Save(Employee objEmp, User objUser) { int result = 0; UserCompany CurrentCompany = new UserCompany(); using (SqlConnection Conn = new SqlConnection(General.GetSQLConnectionString())) { string strSaveQry; if (objEmp.IsNew) { strSaveQry = "INSERT INTO EMPMAST(DBID, EMPCODE, FIRSTNAME, MIDDLENAME, LASTNAME, " + " INITIALS, DEPT, MOBILENO, EMAILID, INACTIVE, " + " EMPPLANT, ST_DATE, MODIFY_DATE, CRBY, MODBY, MACHINENAME) " + " VALUES (@dbId, @EMPCODE, @FIRSTNAME, @MIDDLENAME, @LASTNAME, " + " @INITIALS, @DEPT, @MOBILENO, @EMAILID, @INACTIVE, " + " @EMPPLANT, @STDate, @ModifyDate, @CrBy, @ModBy, @MachineName)"; } else { strSaveQry = "UPDATE EMPMAST " + " SET EMPCODE = @EMPCODE, FIRSTNAME = @FIRSTNAME, MIDDLENAME = @MIDDLENAME, " + " LASTNAME = @LASTNAME, INITIALS = @INITIALS, DEPT = @DEPT, " + " MOBILENO = @MOBILENO, EMAILID = @EMAILID, INACTIVE = @INACTIVE, " + " EMPPLANT = @EMPPLANT, " + " MODIFY_DATE = @ModifyDate, MODBY = @ModBy, MACHINENAME = @MachineName " + " WHERE DBID = @dbId"; } try { SqlCommand objCmd = Conn.CreateCommand(); objCmd.CommandType = CommandType.Text; objCmd.CommandText = strSaveQry; objCmd.Parameters.AddWithValue("@EMPCODE", objEmp.EmpCode); objCmd.Parameters.AddWithValue("@FIRSTNAME", objEmp.FirstName); objCmd.Parameters.AddWithValue("@MIDDLENAME", objEmp.MiddleName); objCmd.Parameters.AddWithValue("@LASTNAME", objEmp.LastName); objCmd.Parameters.AddWithValue("@INITIALS", objEmp.Initials); objCmd.Parameters.AddWithValue("@DEPT", objEmp.DeptID); //objCmd.Parameters.AddWithValue("@JOINDATE", objEmp.JoinDate); //objCmd.Parameters.AddWithValue("@BIRTHDATE", objEmp.BirthDate); //objCmd.Parameters.AddWithValue("@LEFTDATE", objEmp.LeftDate); objCmd.Parameters.AddWithValue("@MOBILENO", objEmp.MobileNo); objCmd.Parameters.AddWithValue("@EMAILID", objEmp.EMailID); objCmd.Parameters.AddWithValue("@INACTIVE", objEmp.InActive); objCmd.Parameters.AddWithValue("@EMPPLANT", objEmp.EmpPlant); if (objEmp.IsNew) { objCmd.Parameters.AddWithValue("@StDate", DateTime.Now); objCmd.Parameters.AddWithValue("@CrBy", objUser.LoginName); //objEmp.DBID = General.GenerateDBID(Conn, "EMPMAST"); objEmp.DBID = General.GenerateDBID("SEQEMPID", Conn); } objCmd.Parameters.AddWithValue("@ModifyDate", DateTime.Now); objCmd.Parameters.AddWithValue("@ModBy", objUser.LoginName); objCmd.Parameters.AddWithValue("@MachineName", General.GetMachineName()); objCmd.Parameters.AddWithValue("@dbID", objEmp.DBID); if (Conn.State != ConnectionState.Open) { Conn.Open(); } result = objCmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } } return(result > 0); }