コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }