/// <summary> /// To check record existence in UOMMast /// </summary> /// <param name="strUOMName"></param> /// <param name="intUOMIdno"></param> /// <returns></returns> public bool IsExists(string strUOMName, int intUOMIdno) { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { UOMMast objUOMMast = new UOMMast(); if (intUOMIdno <= 0) { objUOMMast = (from mast in db.UOMMasts where mast.UOM_Name == strUOMName select mast).FirstOrDefault(); } else if (intUOMIdno > 0) { objUOMMast = (from mast in db.UOMMasts where mast.UOM_Name == strUOMName && mast.UOM_Idno != intUOMIdno select mast).FirstOrDefault(); } if (objUOMMast != null) { return(true); } else { return(false); } } }
public Int32 UpdateStatus(int intUOMIdno, bool Status, Int32 empIdno) { int value = 0; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { UOMMast objUOMMast = (from mast in db.UOMMasts where mast.UOM_Idno == intUOMIdno select mast).FirstOrDefault(); if (objUOMMast != null) { objUOMMast.Status = Status; objUOMMast.Emp_Idno = empIdno; objUOMMast.Date_Modified = System.DateTime.Now; db.SaveChanges(); value = 1; } } } catch (Exception ex) { } return(value); }
/// <summary> /// Delete record from UOMMast /// </summary> /// <param name="intUOMIdno"></param> /// <returns></returns> public int Delete(int intUOMIdno) { int intValue = 0; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { UOMMast objUOMMast = (from mast in db.UOMMasts where mast.UOM_Idno == intUOMIdno select mast).FirstOrDefault(); if (objUOMMast != null) { db.UOMMasts.DeleteObject(objUOMMast); 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> /// Insert records in UOMMast /// </summary> /// <param name="strUOMName"></param> /// <param name="strUOMDesc"></param> /// <param name="bStatus"></param> /// <returns></returns> public Int64 Insert(string strUOMName, string strUOMNameHindi, string strUOMDesc, bool bStatus, Int32 EmpIdno) { Int64 intValue = 0; Int32 intCompIdno = 1; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { UOMMast objUOMMast = new UOMMast(); objUOMMast.UOM_Name = strUOMName; objUOMMast.UOMName_Hindi = strUOMNameHindi; objUOMMast.UOM_Desc = strUOMDesc; objUOMMast.Status = bStatus; objUOMMast.Emp_Idno = EmpIdno; objUOMMast.Comp_Idno = intCompIdno; objUOMMast.Date_Added = System.DateTime.Now; if (IsExists(strUOMName, 0) == true) { intValue = -1; } else { db.UOMMasts.AddObject(objUOMMast); db.SaveChanges(); intValue = objUOMMast.UOM_Idno; } } } catch (Exception ex) { //ApplicationFunction.ErrorLog(ex.ToString()); } return(intValue); }
/// <summary> /// Update records in UOMMast /// </summary> /// <param name="strUOMName"></param> /// <param name="strUOMDesc"></param> /// <param name="bStatus"></param> /// <param name="intUOMIdno"></param> /// <returns></returns> public int Update(string strUOMName, string strUOMNameHindi, string strUOMDesc, bool bStatus, int intUOMIdno, Int32 EmpIdno) { int intValue = 0; Int32 intCompIdno = 1; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { UOMMast objUOMMast = (from mast in db.UOMMasts where mast.UOM_Idno == intUOMIdno select mast).FirstOrDefault(); if (objUOMMast != null) { objUOMMast.UOM_Name = strUOMName; objUOMMast.UOMName_Hindi = strUOMNameHindi; objUOMMast.UOM_Desc = strUOMDesc; objUOMMast.Status = bStatus; objUOMMast.Emp_Idno = EmpIdno; objUOMMast.Comp_Idno = intCompIdno; objUOMMast.Date_Modified = System.DateTime.Now; if (IsExists(strUOMName, intUOMIdno) == true) { intValue = -1; } else { db.SaveChanges(); intValue = intUOMIdno; } } } } catch (Exception ex) { //ApplicationFunction.ErrorLog(ex.ToString()); } return(intValue); }