public Int32 UpdateStatus(int intPCompIdno, bool bStatus, Int32 empIdno) { int value = 0; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { tblPCompanyMaster objPCompanyMaster = (from mast in db.tblPCompanyMasters where mast.PComp_Idno == intPCompIdno select mast).FirstOrDefault(); if (objPCompanyMaster != null) { objPCompanyMaster.Emp_Idno = empIdno; objPCompanyMaster.Status = bStatus; objPCompanyMaster.Date_Modified = System.DateTime.Now; db.SaveChanges(); value = 1; } } } catch (Exception ex) { } return(value); }
/// <summary> /// Delete record from PetrolCompany /// </summary> /// <param name="intColrIdno"></param> /// <returns></returns> public int Delete(int intPCompIdno) { int intValue = 0; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { tblPCompanyMaster objMast = (from mast in db.tblPCompanyMasters where mast.PComp_Idno == intPCompIdno select mast).FirstOrDefault(); if (objMast != null) { db.DeleteObject(objMast); 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> /// Update records in CityMaster /// </summary> /// <param name="strCityName"></param> /// <param name="strAbb"></param> /// <param name="bStatus"></param> /// <param name="intCityIdno"></param> /// <param name="intStateIdno"></param> /// <returns></returns> public Int64 UpdatePCompanyMaster(string strPCompName, Int64 intPCompIdno, bool bStatus, Int32 empIdno) { Int64 value = 0; Int32 intCompIdno = 1; using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { tblPCompanyMaster objPCompanyMaster = (from mast in db.tblPCompanyMasters where mast.PComp_Idno == intPCompIdno select mast).FirstOrDefault(); if (objPCompanyMaster != null) { objPCompanyMaster.Emp_Idno = empIdno; objPCompanyMaster.PComp_Name = strPCompName; objPCompanyMaster.Status = bStatus; objPCompanyMaster.Date_Modified = System.DateTime.Now; if (IsExists(strPCompName, intPCompIdno) == true) { value = -1; } else { db.SaveChanges(); value = intPCompIdno; } } } return(value); }
/// <summary> /// To check record existence in CityMaster /// </summary> /// <param name="strCityName"></param> /// <param name="intStateIdno"></param> /// <param name="intCityIdno"></param> /// <returns></returns> public bool IsExists(string strPCompName, Int64 intPCompIdno) { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { tblPCompanyMaster objPCompanyMaster = null; if (intPCompIdno > 0)///for update { objPCompanyMaster = (from CM in db.tblPCompanyMasters where CM.PComp_Name == strPCompName && CM.PComp_Idno != intPCompIdno select CM).FirstOrDefault(); } else /// for insert { objPCompanyMaster = (from nhu in db.tblPCompanyMasters where nhu.PComp_Name == strPCompName select nhu).FirstOrDefault(); } if (objPCompanyMaster != null) { return(true); } else { return(false); } } }
/// <summary> /// Insert records in CityMaster /// </summary> /// <param name="strCityName"></param> /// <param name="strAbb"></param> /// <param name="intStateIdno"></param> /// <param name="bStatus"></param> /// <returns></returns> public Int64 InsertPCompanyMaster(string strPCompName, bool bStatus, Int32 empIdno) { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { Int64 value; Int32 intCompIdno = 1; tblPCompanyMaster ObjtblPCompanyMaster = new tblPCompanyMaster(); if (IsExists(strPCompName, 0)) { value = -1; } else { ObjtblPCompanyMaster.Emp_Idno = empIdno; ObjtblPCompanyMaster.PComp_Name = strPCompName; ObjtblPCompanyMaster.Status = bStatus; ObjtblPCompanyMaster.Date_Added = System.DateTime.Now; db.AddTotblPCompanyMasters(ObjtblPCompanyMaster); db.SaveChanges(); value = ObjtblPCompanyMaster.PComp_Idno; } return(value); } }