public Int32 UpdateStatus(int intDriverIdno, bool Status, Int32 empIdno) { int value = 0; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { DriverMast objDrivMast = (from mast in db.DriverMasts where mast.Driver_Idno == intDriverIdno select mast).FirstOrDefault(); if (objDrivMast != null) { objDrivMast.Emp_Idno = empIdno; objDrivMast.Status = Status; objDrivMast.Date_Modified = System.DateTime.Now; db.SaveChanges(); value = 1; } } } catch (Exception ex) { } return(value); }
/// <summary> /// Delete record from DriverMast /// </summary> /// <param name="intColrIdno"></param> /// <returns></returns> public int Delete(int intDriverIdno) { int intValue = 0; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { DriverMast objDrivMast = (from mast in db.DriverMasts where mast.Driver_Idno == intDriverIdno select mast).FirstOrDefault(); if (objDrivMast != null) { db.DriverMasts.DeleteObject(objDrivMast); db.SaveChanges(); intValue = 1; } } } catch (Exception Ex) { if (Convert.ToBoolean(Ex.InnerException.Message.Contains("The DELETE statement conflicted with the REFERENCE constraint")) == true) { intValue = -1; } } return(intValue); }
/// <summary> /// To check record existence in DriverMast /// </summary> /// <param name="strDriverName"></param> /// <param name="intColrIdno"></param> /// <returns></returns> public bool IsExists(string strDriverName, int intDriverIdno) { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { DriverMast objDrivMast = new DriverMast(); if (intDriverIdno <= 0) { objDrivMast = (from mast in db.DriverMasts where mast.Driver_Name == strDriverName select mast).FirstOrDefault(); } else if (intDriverIdno > 0) { objDrivMast = (from mast in db.DriverMasts where mast.Driver_Name == strDriverName && mast.Driver_Idno != intDriverIdno select mast).FirstOrDefault(); } if (objDrivMast != null) { return(true); } else { return(false); } } }
public Int64 SavDriverHire(string DriverName, string LicenseNO) { Int64 Value = 0; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { DriverMast ObjExist = (from N in db.DriverMasts where N.Driver_Name == DriverName select N).FirstOrDefault(); if (ObjExist != null) { Value = -1; } else { DriverMast ObjNew = new DriverMast(); ObjNew.Driver_Name = DriverName; ObjNew.License_No = LicenseNO; ObjNew.Status = true; db.DriverMasts.AddObject(ObjNew); db.SaveChanges(); Value = ObjNew.Driver_Idno; } } } catch (Exception Ex) { Value = 0; } return(Value); }
/// <summary> /// Update records in DriverMast /// </summary> /// <param name="strDriverName"></param> /// <param name="strColrCode"></param> /// <param name="bStatus"></param> /// <param name="intColrIdno"></param> /// <returns></returns> /// public int Update(string strDriverName, string strDriverNameHindi, bool bStatus, Int32 intDriverIdno, string strLicense_No, DateTime?dtExpiryDate, bool bVarified, string strAccount_No, Int64 strGaurantor, string strAuthority, Int32 empIdno) { int intValue = 0; // Int32 intDriverIdno = 1; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { DriverMast objDrivMast = (from mast in db.DriverMasts where mast.Driver_Idno == intDriverIdno select mast).FirstOrDefault(); if (objDrivMast != null) { objDrivMast.Emp_Idno = empIdno; objDrivMast.Driver_Name = strDriverName; objDrivMast.DriverName_Hindi = strDriverNameHindi; objDrivMast.Status = bStatus; objDrivMast.Comp_Idno = intCompIdno; objDrivMast.Date_Modified = System.DateTime.Now; objDrivMast.License_No = strLicense_No; objDrivMast.Expiry_Date = dtExpiryDate; objDrivMast.Varified = bVarified; objDrivMast.Account_no = strAccount_No; objDrivMast.Guarantor = strGaurantor; objDrivMast.LicenseAuthority = strAuthority; if (IsExists(strDriverName, intDriverIdno) == true) { intValue = -1; } else { db.SaveChanges(); intValue = intDriverIdno; } } } } catch (Exception ex) { //ApplicationFunction.ErrorLog(ex.ToString()); } return(intValue); }
/// <summary> /// Insert records in DriverMast /// </summary> /// <param name="strDriverName"></param> /// <param name="strColrCode"></param> /// <param name="bStatus"></param> /// <returns></returns>// public int Insert(string strDriverName, string strDriverNameHindi, bool bStatus, string strLicense_No, DateTime?dtExpiryDate, bool bVarified, string strAccount_No, Int64 strGaurantor, string strAuthority, Int32 empIdno) { int intValue = 0; Int32 intDriverIdno = 1; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { DriverMast objDrivMast = new DriverMast(); objDrivMast.Driver_Name = strDriverName; objDrivMast.DriverName_Hindi = strDriverNameHindi; objDrivMast.Status = bStatus; objDrivMast.Emp_Idno = empIdno; objDrivMast.Comp_Idno = intCompIdno; objDrivMast.Date_Added = System.DateTime.Now; objDrivMast.License_No = strLicense_No; objDrivMast.Expiry_Date = dtExpiryDate; objDrivMast.Varified = bVarified; objDrivMast.Account_no = strAccount_No; objDrivMast.Guarantor = strGaurantor; objDrivMast.LicenseAuthority = strAuthority; if (IsExists(strDriverName, 0) == true) { intValue = -1; } else { db.DriverMasts.AddObject(objDrivMast); db.SaveChanges(); intValue = Convert.ToInt32(objDrivMast.Driver_Idno); } } } catch (Exception ex) { //ApplicationFunction.ErrorLog(ex.ToString()); } return(intValue); }