示例#1
0
        public List <List_GetData> GetMaterialGroup()
        {
            PTTGSP_DWSContext db = new PTTGSP_DWSContext();

            var lstGroup = db.TB_Material_Group.Where(w => !w.IsDel && w.IsActive).OrderBy(o => o.sName).ToList().Select(s => new List_GetData
            {
                label = s.sName,
                value = s.nGroupID + ""
            }).ToList();

            return(lstGroup);
        }
        public List <List_TB_Reason> GetReason()
        {
            PTTGSP_DWSContext db = new PTTGSP_DWSContext();

            var lstReason = db.TB_Reason.Where(w => !w.IsDel && w.IsActive).OrderBy(o => o.sName).ToList().Select(s => new List_TB_Reason
            {
                label = s.sName,
                value = s.nReasonID + ""
            }).ToList();

            return(lstReason);
        }
        public IActionResult GetMaterialGroup_SearchData(string sName, string sGroupID, string sIsActive)
        {
            List <V_Material_Category> list_v_material_category = new List <V_Material_Category>();
            PTTGSP_DWSContext          db = new PTTGSP_DWSContext();

            list_v_material_category = db.V_Material_Category.Where(w => (w.sCategoryName.Trim() + w.sCategoryCode.Trim()).Trim().ToLower().Contains(sName ?? "") &&
                                                                    (sIsActive != null ? w.IsActive == (sIsActive == "1") : true) &&
                                                                    (sGroupID != null ? w.nGroupID == sGroupID : true)
                                                                    ).OrderBy(o => o.nOrder).ToList();

            return(Ok(list_v_material_category));
        }
示例#4
0
        public List <List_GetData> GetMaterialCate()
        {
            PTTGSP_DWSContext db = new PTTGSP_DWSContext();

            var lstCate = db.TB_Material_Category.Where(w => !w.IsDel && w.IsActive).OrderBy(o => o.sName).ToList().Select(s => new List_GetData
            {
                label = s.sName,
                value = s.nCategoryID + ""
            }).ToList();

            return(lstCate);
        }
        public IActionResult Savedata(V_Material_Category oV_Material_Category)
        {
            CResutlWebMethod result = new CResutlWebMethod();

            PTTGSP_DWSContext db = new PTTGSP_DWSContext();

            result.sStatus = STFunction.process_Success();

            try
            {
                if (!db.V_Material_Category.Any(w => w.sCategoryName.ToLower().Trim() == oV_Material_Category.sCategoryName.ToLower().Trim() && w.nCategoryID != oV_Material_Category.nCategoryID))
                {
                    if (!db.V_Material_Category.Any(w => w.sCategoryCode.ToLower().Trim() == oV_Material_Category.sCategoryCode.ToLower().Trim() && w.nCategoryID != oV_Material_Category.nCategoryID))
                    {
                        TB_Material_Category otb_material_category = db.TB_Material_Category.Where(w => w.nCategoryID == oV_Material_Category.nCategoryID).FirstOrDefault();

                        if (otb_material_category == null)
                        {
                            otb_material_category         = new TB_Material_Category();
                            otb_material_category.dCreate = DateTime.Now;
                            db.TB_Material_Category.Add(otb_material_category);
                        }
                        otb_material_category.nGroupID      = oV_Material_Category.nGroupID.ToInt();
                        otb_material_category.sCategoryCode = oV_Material_Category.sCategoryCode;
                        otb_material_category.sName         = oV_Material_Category.sCategoryName;
                        otb_material_category.sDetail       = oV_Material_Category.sDetail;
                        otb_material_category.nOrder        = oV_Material_Category.nOrder;
                        otb_material_category.IsActive      = oV_Material_Category.IsActive;

                        otb_material_category.dUpdate = DateTime.Now;

                        db.SaveChanges();
                    }
                    else
                    {
                        result.sMsg    = "รหัสประเภทวัสดุนี้มีในระบบแล้ว";
                        result.sStatus = STFunction.process_Warning();
                    }
                }
                else
                {
                    result.sMsg    = "ชื่อประเภทวัสดุนี้มีในระบบแล้ว";
                    result.sStatus = STFunction.process_Warning();
                }
            }
            catch (Exception e)
            {
                result.sStatus = STFunction.process_Failed();
                result.sMsg    = e.ToString();
            }
            return(Ok(result));
        }
        public List <List_TB_Material> GetMaterial()
        {
            PTTGSP_DWSContext db = new PTTGSP_DWSContext();
            var lstWorkMaterials = db.TB_Materials.Where(w => !w.IsDel && w.IsActive).OrderBy(o => o.nMaterialID).ToList().Select(s => new List_TB_Material
            {
                value        = s.nMaterialID.ToString(),
                label        = s.sMaterialCode + " " + ":" + " " + s.sName,
                MaterialCode = s.sMaterialCode + " " + s.sName,
                sUnitname    = db.TB_Material_Unit.FirstOrDefault(w => w.nUnitID == s.nUnitID).sName,
            }).ToList();

            return(lstWorkMaterials);
        }
        public List <List_GetData> GetTB_Materials()
        {
            List <List_GetData> list_getdata = new List <List_GetData>();
            PTTGSP_DWSContext   db           = new PTTGSP_DWSContext();

            list_getdata = db.TB_Materials.Where(w => !w.IsDel && w.IsActive).OrderBy(o => o.sName).ToList().Select(s => new List_GetData
            {
                label = s.sName,
                value = s.nMaterialID + ""
            }).ToList();;

            return(list_getdata);
        }
示例#8
0
        public List <V_Withdrawal_Status> GetV_Withdrawal_Status_SearchData(string sStepID, string sStartDate, string sEndDate)
        {
            PTTGSP_DWSContext          db = new PTTGSP_DWSContext();
            List <V_Withdrawal_Status> listv_withdrawal_status = new List <V_Withdrawal_Status>();

            string Exceq      = "EXEC [dbo].[Stp_Withdrawal_Status_SearchData] '" + sStartDate + "','" + sEndDate + "','" + sStepID + "'";
            var    JsonString = STFunction.QryToJson(Exceq, "");

            listv_withdrawal_status = JsonConvert.DeserializeObject <List <V_Withdrawal_Status> >(JsonString);


            return(listv_withdrawal_status);
        }
        public List <V_Materials> GetV_Materials(string sRequestID)
        {
            List <V_Materials> ov_materials = new List <V_Materials>();
            PTTGSP_DWSContext  db           = new PTTGSP_DWSContext();

            ov_materials = db.V_Materials.Where(w => w.nRequestID == sRequestID.ToInt()).OrderBy(o => o.sMaterialCode).ToList();
            if (ov_materials == null)
            {
                ov_materials = new List <V_Materials>();
            }

            return(ov_materials);
        }
示例#10
0
        public List <V_User> User_Permission_SearchData(string sFullname, string sIsActive, string sRoleID)
        {
            List <V_User>     tb_user = new List <V_User>();
            PTTGSP_DWSContext db      = new PTTGSP_DWSContext();

            int nRoleID = sRoleID.ToInt();

            tb_user = db.V_User.Where(w => (w.sName.Trim().ToLower().Contains(sFullname ?? "")) &&
                                      (sIsActive != null ? w.IsActive == (sIsActive == "1") : true) &&
                                      (string.IsNullOrEmpty(sRoleID) ? true : (w.nSubID == nRoleID))
                                      ).OrderBy(o => o.sEmployeeID).ToList();
            return(tb_user);
        }
示例#11
0
        public IActionResult User_Permission_edit(string sEmployeeID)
        {
            TB_User           tb_user  = new TB_User();
            PTTGSP_DWSContext db       = new PTTGSP_DWSContext();
            TB_User           qtb_user = db.TB_User.Where(w => w.sEmployeeID == sEmployeeID).FirstOrDefault();

            if (qtb_user != null)
            {
                tb_user = qtb_user;
            }

            return(Ok(tb_user));
        }
示例#12
0
        public IActionResult GetData_Edit(int nID)
        {
            TB_Materials   lstMaterials = new TB_Materials();
            List <lstFile> File         = new List <lstFile>();
            List <lstFile> lstFile      = new List <lstFile>();

            db = new PTTGSP_DWSContext();
            if (nID != 0)
            {
                lstMaterials = db.TB_Materials.FirstOrDefault(f => f.nMaterialID == nID);
                var lstFiles = db.TB_Materials_File.Where(w => w.nMaterialID == lstMaterials.nMaterialID).ToList();

                if (lstMaterials != null)
                {
                    lstFile f = new lstFile();
                    f.sFileName       = lstMaterials.sFile_Name;
                    f.sSaveToFileName = lstMaterials.sFile_SysName;
                    f.sSize           = "0";
                    f.sSaveToPath     = lstMaterials.sFile_Path;
                    f.IsNewFile       = false;
                    f.IsDelete        = false;
                    File.Add(f);
                }

                foreach (var i in lstFiles)
                {
                    lstFile f = new lstFile();
                    f.nFileID         = i.nItem;
                    f.sFileName       = i.sFile_Name;
                    f.sSaveToFileName = i.sFile_SysName;
                    f.sSize           = "0";
                    f.sSaveToPath     = i.sFile_Path;
                    f.IsNewFile       = false;
                    f.IsDelete        = false;
                    lstFile.Add(f);
                }
            }
            else
            {
                lstMaterials = null;
            }

            var lstUnits    = db.TB_Material_Unit.Where(w => !w.IsDel && w.IsActive).ToList();
            var lstCategory = db.TB_Material_Category.Where(w => !w.IsDel && w.IsActive).ToList();
            var lstGroup    = db.TB_Material_Group.Where(w => !w.IsDel && w.IsActive).ToList();
            var lstLocation = db.TB_Material_Location.Where(w => !w.IsDel && w.IsActive).ToList();

            return(Ok(new { lstMaterials, lstFile, lstUnits, lstCategory, lstGroup, lstLocation, File }));
        }
示例#13
0
        public IActionResult ParcelGroup_Edit(string sGroupID)
        {
            int nGroupID = sGroupID.ToInt();

            TB_Material_Group tb_material_group = new TB_Material_Group();
            PTTGSP_DWSContext db = new PTTGSP_DWSContext();

            tb_material_group = db.TB_Material_Group.Where(w => w.nGroupID == nGroupID && w.IsDel == false).FirstOrDefault();
            if (tb_material_group == null)
            {
                tb_material_group          = new TB_Material_Group();
                tb_material_group.IsActive = true;
            }
            return(Ok(tb_material_group));
        }
        public List <Stock_Update_List> GetStock_Update_List(int nRequestID)
        {
            List <Stock_Update_List> liststock_update_list = new List <Stock_Update_List>();

            PTTGSP_DWSContext db = new PTTGSP_DWSContext();

            ///V_Stock_Update
            List <V_Stock_Update> listv_stock_update = db.V_Stock_Update.Where(w => w.nStepID == 1).OrderBy(o => o.sRequestNo).ToList();


            if (listv_stock_update != null)
            {
                foreach (V_Stock_Update i in listv_stock_update)
                {
                    Stock_Update_List ostock_update_list = new Stock_Update_List();
                    ostock_update_list.oV_Materials = new List <V_Materials>();

                    ostock_update_list.sRequestNo = i.sRequestNo;
                    ostock_update_list.nRequestID = i.nRequestID;
                    ostock_update_list.sReason    = i.sReason;
                    ostock_update_list.nCreateBy  = i.nCreateBy;
                    ostock_update_list.sUpdate    = i.sUpdate;
                    ostock_update_list.dUpdate    = i.dUpdate;
                    ostock_update_list.sStep      = i.sStep;
                    ostock_update_list.nStepID    = i.nStepID;
                    ostock_update_list.sNote      = i.sNote;


                    //V_Materials
                    List <V_Materials> V_Materials = db.V_Materials.Where(w => w.nRequestID == i.nRequestID).OrderBy(o => o.sMaterialCode).ToList();

                    if (V_Materials != null)
                    {
                        foreach (V_Materials m in V_Materials)
                        {
                            V_Materials ov_materials = new V_Materials();

                            ov_materials = m;
                            ostock_update_list.oV_Materials.Add(ov_materials);
                        }
                    }

                    liststock_update_list.Add(ostock_update_list);
                }
            }

            return(liststock_update_list);
        }
        public void SetOrderAll()
        {
            PTTGSP_DWSContext           db = new PTTGSP_DWSContext();
            List <TB_Material_Category> listtb_material_category = db.TB_Material_Category.Where(w => w.IsDel == false).OrderBy(o => o.nOrder).ToList();

            if (listtb_material_category != null)
            {
                int neworder = 1;
                foreach (TB_Material_Category otb_material_category in listtb_material_category)
                {
                    otb_material_category.nOrder = neworder;
                    neworder++;
                }
                db.SaveChanges();
            }
        }
示例#16
0
        public void SetOrderAll()
        {
            PTTGSP_DWSContext        db = new PTTGSP_DWSContext();
            List <TB_Material_Group> listtb_material_group = db.TB_Material_Group.Where(w => w.IsDel == false).OrderBy(o => o.nOrder).ToList();

            if (listtb_material_group != null)
            {
                int neworder = 1;
                foreach (TB_Material_Group otb_material_group in listtb_material_group)
                {
                    otb_material_group.nOrder = neworder;
                    neworder++;
                }
                db.SaveChanges();
            }
        }
        public V_Material_Category ParcelType_Edit(string sCategoryID)
        {
            V_Material_Category ov_material_category = new V_Material_Category();
            PTTGSP_DWSContext   db = new PTTGSP_DWSContext();

            ov_material_category = db.V_Material_Category.Where(w => w.nCategoryID == sCategoryID.ToInt()).OrderBy(o => o.nOrder).FirstOrDefault();
            if (ov_material_category == null)
            {
                ov_material_category          = new V_Material_Category();
                ov_material_category.IsActive = true;
                ov_material_category.nGroupID = "";
            }


            return(ov_material_category);
        }
        public List <Stock_Update_List> Request_to_ImproveStock_SearchData(string sRequestNo, string sStepID, string sStartDate, string sEndDate)
        {
            List <Stock_Update_List> liststock_update_list = new List <Stock_Update_List>();
            PTTGSP_DWSContext        db = new PTTGSP_DWSContext();

            DateTime dStartDate = Convert.ToDateTime(sStartDate ?? "1900-01-01");
            DateTime dEndDate   = Convert.ToDateTime(sEndDate ?? "9999-01-01");


            liststock_update_list = GetStock_Update_List(0).Where(w => w.sRequestNo.Trim().Contains(sRequestNo ?? "") &&
                                                                  (sStepID != null ? w.nStepID == sStepID.ToInt() : true) &&
                                                                  (w.dUpdate >= dStartDate && w.dUpdate <= dEndDate)
                                                                  ).OrderBy(o => o.sRequestNo).ToList();

            return(liststock_update_list);
        }
        public V_Stock_Update Request_to_ImproveStock_Edit(string sRequestID)
        {
            V_Stock_Update    ov_stock_update = new V_Stock_Update();
            PTTGSP_DWSContext db = new PTTGSP_DWSContext();

            ov_stock_update = db.V_Stock_Update.Where(w => w.nRequestID == sRequestID.ToInt()).FirstOrDefault();
            if (ov_stock_update == null)
            {
                ov_stock_update           = new V_Stock_Update();
                ov_stock_update.sUpdatekc = DateTime.Now.ToStringFromDate();
                ov_stock_update.dUpdate   = DateTime.Now;
            }



            return(ov_stock_update);
        }
示例#20
0
        public int MenuAccessible(int nMenuID)
        {
            int n = 0;

            var db   = new PTTGSP_DWSContext();
            var menu = db.TM_Menu.FirstOrDefault(w => w.IsBackend && w.IsActive && w.nMenuID == nMenuID);

            if (menu != null)
            {
                var prms = db.TM_Permission.FirstOrDefault(w => w.nMenuID == nMenuID && w.nRole == nRoleID);
                if (prms != null)
                {
                    n = prms.nPermission;
                }
            }

            return(n);
        }
        public cListJobDescription GetListWork(string txtSearch, string sIsActive)
        {
            var result = new cListJobDescription();

            try
            {
                PTTGSP_DWSContext db = new PTTGSP_DWSContext();

                var lst_Work       = db.TB_Work.Where(w => !w.IsDel).ToList();
                var lstReason      = db.TB_Reason.Where(w => !w.IsDel).ToList();
                var Jobdescription = (from s in lst_Work
                                      from g in lstReason.Where(w => w.nReasonID == s.nReasonID)
                                      select new lst_Work
                {
                    nWorkID = s.nWorkID,
                    sName = s.sName,
                    nReasonID = s.nReasonID,
                    sReason = g.sName,
                    sDetail = s.sDetail,
                    bStatus = s.IsActive,
                    sStatus_Name = s.IsActive ? "ใช้งาน" : "ไม่ใช้งาน",
                    dUpdate = s.dUpdate,
                    sUpdate = s.dUpdate.ToString("dd/MM/yyyy", culture),
                }).ToList();

                if (!string.IsNullOrEmpty(txtSearch) && txtSearch != "none")
                {
                    Jobdescription = Jobdescription.Where(item => item.sName.Trim().ToLower().Contains(txtSearch.Trim().ToLower())).ToList();
                }
                if (!string.IsNullOrEmpty(sIsActive))
                {
                    var isActive = sIsActive == "1";
                    Jobdescription = Jobdescription.Where(a => a.bStatus == isActive).ToList();
                }

                result.lst_Work = Jobdescription.ToList();
            }
            catch (Exception e)
            {
                result.sStatus = SysFunc.process_Error;
                result.sMsg    = e.Message;
            }
            return(result);
        }
        public IActionResult GetData_List()
        {
            List <GetLimit_lst> lst = new List <GetLimit_lst>();

            db = new PTTGSP_DWSContext();
            var lstData = db.TM_Config.ToList();

            foreach (var i in lstData)
            {
                GetLimit_lst l = new GetLimit_lst();
                l.nID          = i.nID;
                l.sName        = i.sName;
                l.sValue       = i.sValue;
                l.nValue       = i.nValue;
                l.sDescription = i.sDescription;
                lst.Add(l);
            }
            return(Ok(lst));
        }
        public cListMaterialLocation GetListMaterialLocation(string txtSearch, string sIsActive)
        {
            var result = new cListMaterialLocation();

            try
            {
                PTTGSP_DWSContext db = new PTTGSP_DWSContext();

                var lstMaterial_location = db.TB_Material_Location.Where(w => !w.IsDel).ToList();
                var lstMaterial          = db.TB_Materials.Where(w => !w.IsDel).ToList();
                var Meterial_Location    = lstMaterial_location.Select(s => new lstMaterial_location
                {
                    nLocationID  = s.nLocationID,
                    sName        = s.sName,
                    sDetail      = s.sDetail,
                    bStatus      = s.IsActive,
                    sStatus_Name = s.IsActive ? "ใช้งาน" : "ไม่ใช้งาน",
                    dUpdate      = s.dUpdate,
                    sUpdate      = s.dUpdate.ToString("dd/MM/yyyy", culture),
                    IsUse        = lstMaterial.Where(w => w.nLocationID == s.nLocationID).FirstOrDefault() == null ? false : true
                                   //  IsUse = g.nLocationID == 0 ? false : true
                }).ToList();

                if (!string.IsNullOrEmpty(txtSearch) && txtSearch != "none")
                {
                    Meterial_Location = Meterial_Location.Where(item => item.sName.Trim().ToLower().Contains(txtSearch.Trim().ToLower())).ToList();
                }
                if (!string.IsNullOrEmpty(sIsActive))
                {
                    var isActive = sIsActive == "1";
                    Meterial_Location = Meterial_Location.Where(a => a.bStatus == isActive).ToList();
                }

                result.lstMaterial_location = Meterial_Location.ToList();
            }
            catch (Exception e)
            {
                result.sStatus = SysFunc.process_Error;
                result.sMsg    = e.Message;
            }
            return(result);
        }
        public ResultAPI SaveData(List <GetLimit_lst> data)
        {
            db = new PTTGSP_DWSContext();
            ResultAPI result = new ResultAPI();

            try
            {
                foreach (var i in data)
                {
                    if (i.sValue.ToDecimalOrNull() != null)
                    {
                        var Update = db.TM_Config.FirstOrDefault(f => f.nID == i.nID);
                        if (Update != null)
                        {
                            Update.nValue = i.sValue.ToDecimalOrNull();
                        }
                        else
                        {
                            result.Message = "ข้อมูลไม่ถูกต้อง !";
                            result.Status  = ResultStatus.Error;
                            return(result);
                        }
                        db.SaveChanges();
                    }
                    else
                    {
                        result.Message = "จำนวนเงินวงเงินไม่ถูกต้อง !";
                        result.Status  = ResultStatus.Warning;
                        return(result);
                    }
                }
                result.Status = ResultStatus.Success;
                return(result);
            }
            catch (Exception er)
            {
                result.Message = er.Message;
                result.Status  = ResultStatus.Error;
                return(result);
            }
        }
示例#25
0
        public IActionResult Savedata(TB_Material_Group TB_Material_Group)
        {
            CResutlWebMethod  result = new CResutlWebMethod();
            PTTGSP_DWSContext db     = new PTTGSP_DWSContext();

            result.sStatus = STFunction.process_Success();

            try
            {
                if (!db.TB_Material_Group.Any(w => w.sName.ToLower().Trim() == TB_Material_Group.sName.ToLower().Trim() && w.nGroupID != TB_Material_Group.nGroupID && w.IsDel != true))
                {
                    TB_Material_Group tb_material_group = db.TB_Material_Group.Where(w => w.nGroupID == TB_Material_Group.nGroupID).FirstOrDefault();

                    if (tb_material_group == null)
                    {
                        tb_material_group         = new TB_Material_Group();
                        tb_material_group.dCreate = DateTime.Now;
                        db.TB_Material_Group.Add(tb_material_group);
                    }
                    tb_material_group.sName    = TB_Material_Group.sName;
                    tb_material_group.sDetail  = TB_Material_Group.sDetail;
                    tb_material_group.nOrder   = TB_Material_Group.nOrder;
                    tb_material_group.IsActive = TB_Material_Group.IsActive;
                    tb_material_group.dUpdate  = DateTime.Now;

                    db.SaveChanges();
                }
                else
                {
                    result.sMsg    = "ชื่อกลุ่มวัสดุนี้มีในระบบแล้ว";
                    result.sStatus = STFunction.process_Warning();
                }
            }
            catch (Exception e)
            {
                result.sStatus = STFunction.process_Failed();
                result.sMsg    = e.ToString();
            }
            return(Ok(result));
        }
示例#26
0
        public ActionResult SearchTitle(string txtSearch, string sIsActive, string nCategoryID, string nGroupID)
        {
            db = new PTTGSP_DWSContext();
            bool?IsActive = null;

            if (sIsActive == "1")
            {
                IsActive = true;
            }
            else if (sIsActive == "2")
            {
                IsActive = false;
            }

            var lstData = (from Materials in db.TB_Materials.Where(w => (txtSearch != null ? (w.sMaterialCode + w.sName).Trim().ToLower().Contains(txtSearch.Trim().ToLower()) : true) &&
                                                                   (sIsActive != null ? w.IsActive == IsActive : true) &&
                                                                   (nCategoryID != null && nCategoryID != "0" ? w.nCategoryID == nCategoryID.ToIntOrZero() : true) &&
                                                                   (nGroupID != null && nGroupID != "0" ? w.nGroupID == nGroupID.ToIntOrZero() : true) &&
                                                                   !w.IsDel)
                           from Units in db.TB_Material_Unit.Where(w => w.nUnitID == Materials.nUnitID && !w.IsDel)
                           from Balance in db.TB_Materials_BP.Where(w => w.nMaterialID == Materials.nMaterialID).DefaultIfEmpty()
                           select new
            {
                Materials.nMaterialID,
                Materials.sMaterialCode,
                Materials.sName,
                Materials.sFile_Path,
                Materials.nPrice,
                UnitsName = Units.sName,
                nMat_Balance = Balance != null ? Balance.nMat_Balance : 0,
                Materials.nMax,
                Materials.nMin,
                Materials.IsActive,
                Materials.dUpdate,
            }).OrderByDescending(o => o.dUpdate).ToList();

            return(Ok(lstData));
        }
        public SysModalGlobal.CResutlWebMethod DeleteData(string str)
        {
            PTTGSP_DWSContext db = new PTTGSP_DWSContext();

            SysModalGlobal.CResutlWebMethod result = new SysModalGlobal.CResutlWebMethod();

            try
            {
                if (!String.IsNullOrEmpty(str))
                {
                    var data   = str.Split(',').Select(Int32.Parse).ToList();
                    var lstnID = db.TB_Material_Location.Where(w => !w.IsDel).ToList();

                    var lstMaterial = db.TB_Materials.Where(w => !w.IsDel).ToList();


                    var lstData = lstnID.Where(w => data.Contains(w.nLocationID)).ToList();
                    lstData.ForEach(f =>
                    {
                        var IsUse = lstMaterial.Where(w => w.nLocationID == f.nLocationID).ToList();
                        if (IsUse.Count() == 0)
                        {
                            f.IsDel = true;
                        }
                    });

                    db.SaveChanges();
                    result.sStatus = SysFunc.process_Success;
                }
            }
            catch (Exception e)
            {
                result.sStatus = SysFunc.process_Error;
                result.sMsg    = e.Message;
            }
            return(result);
        }
        public ActionResult SearchTNewbyTitle(string txtSearch, string sIsActive)
        {
            db = new PTTGSP_DWSContext();
            bool?IsActive = null;

            if (sIsActive == "1")
            {
                IsActive = true;
            }
            else if (sIsActive == "2")
            {
                IsActive = false;
            }

            var qData = db.TB_Vendor.Where(w => (txtSearch != null ? (w.sCompanyName + w.sContactName).Trim().ToLower().Contains(txtSearch.Trim().ToLower()) : true) && (sIsActive != null ? w.IsActive == IsActive : true) && !w.IsDel).OrderByDescending(o => o.dUpdate).ToList();

            List <GetSeller_Edit> lstdata = new List <GetSeller_Edit>();
            int Count = 1;

            foreach (var i in qData)
            {
                GetSeller_Edit s = new GetSeller_Edit();
                s.nVendorID    = i.nVendorID;
                s.sCompanyCode = i.sCompanyCode;
                s.sCompanyName = i.sCompanyName;
                s.sContactName = i.sContactName;
                s.sDetail      = i.sDetail;
                s.sEmail       = i.sEmail;
                s.sTel         = i.sTel;
                s.nRow         = Count;
                s.IsActive     = i.IsActive == true ? "0" : "1";
                Count++;
                lstdata.Add(s);
            }

            return(Ok(lstdata));
        }
        public IActionResult GetMaterialGroup__Del_data(int[] nCategoryID)
        {
            CResutlWebMethod  result = new CResutlWebMethod();
            PTTGSP_DWSContext db     = new PTTGSP_DWSContext();

            if (nCategoryID.Length > 0)
            {
                List <TB_Material_Category> listtb_material_category = db.TB_Material_Category.Where(w => nCategoryID.Contains(w.nCategoryID)).ToList();

                foreach (var i in listtb_material_category)
                {
                    i.IsDel = true;
                    db.SaveChanges();
                }
                SetOrderAll();
                result.sStatus = STFunction.process_Success();
            }
            else
            {
                result.sStatus = STFunction.process_Warning();
            }

            return(Ok(result));
        }
示例#30
0
        public List <lstAutoCompleted> SetVauleAutoCompleted()
        {
            List <lstAutoCompleted> lst = new List <lstAutoCompleted>();

            db = new PTTGSP_DWSContext();

            var Materials = (from MR in db.TB_Materials.Where(w => w.IsActive && !w.IsDel)
                             from MU in db.TB_Material_Unit.Where(w => !w.IsDel && w.IsActive && w.nUnitID == MR.nUnitID)
                             select new lstAutoCompleted
            {
                nMaterialID = MR.nMaterialID,
                value = MR.nMaterialID + "",
                label = MR.sMaterialCode + " " + ":" + " " + MR.sName,
                sMaterialCode = MR.sMaterialCode + " " + MR.sName,
                MaterialCode = MR.sMaterialCode,
                MaterialName = MR.sName,
                nUnitID = MR.nUnitID,
                nPrice = MR.nPrice,
                sUnitName = MU.sName
            }
                             ).ToList();

            return(Materials);
        }