/// <summary> /// Insert records in tblIGrpMast /// </summary> /// <param name="strIGroupName"></param> /// <param name="intIGrpType"></param> /// <param name="bStatus"></param> /// <returns></returns> public Int64 Insert(string strConType, bool bStatus, Int32 empIdno) { Int64 intValue = 0; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { tblContainerType objConTypeMast = new tblContainerType(); objConTypeMast.Emp_Idno = empIdno; objConTypeMast.Container_Type = strConType; objConTypeMast.Status = bStatus; objConTypeMast.Date_Added = System.DateTime.Now; if (IsExists(strConType, 0) == true) { intValue = -1; } else { db.tblContainerTypes.AddObject(objConTypeMast); db.SaveChanges(); intValue = objConTypeMast.ContainerType_Idno; } } } catch (Exception ex) { //ApplicationFunction.ErrorLog(ex.ToString()); } return(intValue); }
/// <summary> /// To Check data Already Exist or Not /// </summary> /// <param name="strIGroupName"></param> /// <param name="intIGropIdno"></param> /// <returns></returns> public bool IsExists(string strConType, int intConTypeIdno) { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { tblContainerType objConTypeMast = new tblContainerType(); if (intConTypeIdno <= 0) { objConTypeMast = (from mast in db.tblContainerTypes where mast.Container_Type == strConType select mast).FirstOrDefault(); } else if (intConTypeIdno > 0) { objConTypeMast = (from mast in db.tblContainerTypes where mast.Container_Type == strConType && mast.ContainerType_Idno != intConTypeIdno select mast).FirstOrDefault(); } if (objConTypeMast != null) { return(true); } else { return(false); } } }
/// <summary> /// Delete Record from tblIGrpMast /// </summary> /// <param name="intIGropIdno"></param> /// <returns></returns> public int Delete(int intConTypeIdno) { int intValue = 0; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { tblContainerType objConTypeMast = (from mast in db.tblContainerTypes where mast.ContainerType_Idno == intConTypeIdno select mast).FirstOrDefault(); if (objConTypeMast != null) { db.tblContainerTypes.DeleteObject(objConTypeMast); 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); }
public Int32 UpdateStatus(int intConTypeIdno, bool Status, Int32 empIdno) { int value = 0; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { tblContainerType objConTypeMast = (from mast in db.tblContainerTypes where mast.ContainerType_Idno == intConTypeIdno select mast).FirstOrDefault(); if (objConTypeMast != null) { objConTypeMast.Emp_Idno = empIdno; objConTypeMast.Status = Status; objConTypeMast.Date_Modified = System.DateTime.Now; db.SaveChanges(); value = 1; } } } catch (Exception ex) { } return(value); }
/// <summary> /// To Update Record in tblIGrpMast /// </summary> /// <param name="strIGroupName"></param> /// <param name="intIGrpType"></param> /// <param name="bStatus"></param> /// <param name="intIGropIdno"></param> /// <returns></returns> public int Update(string strConType, bool bStatus, int intConTypeIdno, Int32 empIdno) { int intValue = 0; try { using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString())) { tblContainerType objConTypeMast = (from mast in db.tblContainerTypes where mast.ContainerType_Idno == intConTypeIdno select mast).FirstOrDefault(); if (objConTypeMast != null) { objConTypeMast.Emp_Idno = empIdno; objConTypeMast.Container_Type = strConType; objConTypeMast.Status = bStatus; objConTypeMast.Date_Modified = System.DateTime.Now; if (IsExists(strConType, intConTypeIdno) == true) { intValue = -1; } else { db.SaveChanges(); intValue = intConTypeIdno; } } } } catch (Exception ex) { //ApplicationFunction.ErrorLog(ex.ToString()); } return(intValue); }