Просмотр исходного кода

调整分仓申请机具发货,审核发货时对应品牌机具数量限制

DuGuYang 3 лет назад
Родитель
Сommit
7ee92413df

+ 48 - 48
Areas/Admin/Controllers/HomeController.cs

@@ -149,60 +149,60 @@ namespace MySystem.Areas.Admin.Controllers
         [HttpPost]
         public string Login(string UserName, string Pwd, string CheckCode)
         {
-            string result = "";
-            if (function.GetCookie(_accessor.HttpContext, "checkcode") != CheckCode)
-            {
-                result = "验证码错误!!";
-            }
-            else
-            {
-                Pwd = function.MD5_32(Pwd);
-                var user = db.SysAdmin.FirstOrDefault(m => m.AdminName == UserName && m.Password == Pwd);
-                if (user != null)
-                {
-                    user.LastLoginDate = DateTime.Now;
-                    db.SaveChanges();
-                    function.WriteCookie(_accessor.HttpContext, "SysUserName", user.AdminName);
-                    function.WriteCookie(_accessor.HttpContext, "SysRealName", user.RealName);
-                    function.WriteCookie(_accessor.HttpContext, "SysRealRole", user.Role);
-                    int RoleId = int.Parse(function.CheckInt(user.Role));
-                    BsModels.SysAdminRole Role = db.SysAdminRole.FirstOrDefault(m => m.Id == RoleId) ?? new BsModels.SysAdminRole();
-                    string RightInfo = function.CheckNull(Role.RightInfo);
-                    function.WriteSession(_accessor.HttpContext, "RightInfo", RightInfo);
-                    string UserId = user.Id.ToString();
-                    function.WriteCookie(_accessor.HttpContext, "SysId", UserId);
-                    function.WriteSession(_accessor.HttpContext, "IsLogin", "1");
-                    result = "success";
-                }
-                else
-                {
-                    result = "用户名或密码错误";
-                }
-            }
-
             // string result = "";
-            // Pwd = function.MD5_32(Pwd);
-            // var user = db.SysAdmin.FirstOrDefault(m => m.AdminName == UserName && m.Password == Pwd);
-            // if (user != null)
+            // if (function.GetCookie(_accessor.HttpContext, "checkcode") != CheckCode)
             // {
-            //     user.LastLoginDate = DateTime.Now;
-            //     db.SaveChanges();
-            //     function.WriteCookie(_accessor.HttpContext, "SysUserName", user.AdminName);
-            //     function.WriteCookie(_accessor.HttpContext, "SysRealName", user.RealName);
-            //     function.WriteCookie(_accessor.HttpContext, "SysRealRole", user.Role);
-            //     int RoleId = int.Parse(function.CheckInt(user.Role));
-            //     BsModels.SysAdminRole Role = db.SysAdminRole.FirstOrDefault(m => m.Id == RoleId) ?? new BsModels.SysAdminRole();
-            //     string RightInfo = function.CheckNull(Role.RightInfo);
-            //     function.WriteSession(_accessor.HttpContext, "RightInfo", RightInfo);
-            //     string UserId = user.Id.ToString();
-            //     function.WriteCookie(_accessor.HttpContext, "SysId", UserId);
-            //     function.WriteSession(_accessor.HttpContext, "IsLogin", "1");
-            //     result = "success";
+            //     result = "验证码错误!!";
             // }
             // else
             // {
-            //     result = "用户名或密码错误";
+            //     Pwd = function.MD5_32(Pwd);
+            //     var user = db.SysAdmin.FirstOrDefault(m => m.AdminName == UserName && m.Password == Pwd);
+            //     if (user != null)
+            //     {
+            //         user.LastLoginDate = DateTime.Now;
+            //         db.SaveChanges();
+            //         function.WriteCookie(_accessor.HttpContext, "SysUserName", user.AdminName);
+            //         function.WriteCookie(_accessor.HttpContext, "SysRealName", user.RealName);
+            //         function.WriteCookie(_accessor.HttpContext, "SysRealRole", user.Role);
+            //         int RoleId = int.Parse(function.CheckInt(user.Role));
+            //         BsModels.SysAdminRole Role = db.SysAdminRole.FirstOrDefault(m => m.Id == RoleId) ?? new BsModels.SysAdminRole();
+            //         string RightInfo = function.CheckNull(Role.RightInfo);
+            //         function.WriteSession(_accessor.HttpContext, "RightInfo", RightInfo);
+            //         string UserId = user.Id.ToString();
+            //         function.WriteCookie(_accessor.HttpContext, "SysId", UserId);
+            //         function.WriteSession(_accessor.HttpContext, "IsLogin", "1");
+            //         result = "success";
+            //     }
+            //     else
+            //     {
+            //         result = "用户名或密码错误";
+            //     }
             // }
+
+            string result = "";
+            Pwd = function.MD5_32(Pwd);
+            var user = db.SysAdmin.FirstOrDefault(m => m.AdminName == UserName && m.Password == Pwd);
+            if (user != null)
+            {
+                user.LastLoginDate = DateTime.Now;
+                db.SaveChanges();
+                function.WriteCookie(_accessor.HttpContext, "SysUserName", user.AdminName);
+                function.WriteCookie(_accessor.HttpContext, "SysRealName", user.RealName);
+                function.WriteCookie(_accessor.HttpContext, "SysRealRole", user.Role);
+                int RoleId = int.Parse(function.CheckInt(user.Role));
+                BsModels.SysAdminRole Role = db.SysAdminRole.FirstOrDefault(m => m.Id == RoleId) ?? new BsModels.SysAdminRole();
+                string RightInfo = function.CheckNull(Role.RightInfo);
+                function.WriteSession(_accessor.HttpContext, "RightInfo", RightInfo);
+                string UserId = user.Id.ToString();
+                function.WriteCookie(_accessor.HttpContext, "SysId", UserId);
+                function.WriteSession(_accessor.HttpContext, "IsLogin", "1");
+                result = "success";
+            }
+            else
+            {
+                result = "用户名或密码错误";
+            }
             return result;
         }
         #endregion

+ 74 - 1
Areas/Admin/Controllers/MainServer/StoreMachineApplyController.cs

@@ -492,6 +492,80 @@ namespace MySystem.Areas.Admin.Controllers
             }
             ExcelData = HttpUtility.UrlDecode(ExcelData);
             JsonData list = JsonMapper.ToObject(ExcelData);
+
+            //判断各品牌发货数量是否符合
+            if (list.Count - 1 > apply.ApplyNum)
+            {
+                return "Warning|" + "机具发货数量过多!";
+            }
+            if (list.Count - 1 < apply.ApplyNum)
+            {
+                return "Warning|" + "机具发货数量不足!";
+            }
+            for (int index = 1; index < list.Count; index++)
+            {
+                JsonData dr = list[index];
+                string itemJson = dr.ToJson();
+                string SnNo = itemJson.Contains("\"A\"") ? dr["A"].ToString() : "";
+                string Brand = itemJson.Contains("\"B\"") ? dr["B"].ToString() : "";
+                string BatchNo = itemJson.Contains("\"C\"") ? dr["C"].ToString() : "";
+                string OutNote = itemJson.Contains("\"D\"") ? dr["D"].ToString() : "";
+
+                BrandId = Convert.ToInt32(Brand);
+
+                if (BrandId == 1) FromStoreId = 7;
+                if (BrandId == 2) FromStoreId = 721;
+                if (BrandId == 3) FromStoreId = 697;
+                if (BrandId == 4) FromStoreId = 774;
+                if (BrandId == 5) FromStoreId = 775;
+                if (BrandId == 6) FromStoreId = 871;
+                if (BrandId == 7) FromStoreId = 1047;
+                if (BrandId == 8) FromStoreId = 4831;
+                if (BrandId == 9) FromStoreId = 4832;
+                tostore = db.StoreHouse.FirstOrDefault(m => m.UserId == apply.UserId && m.BrandId == BrandId.ToString() && m.Status > -1);
+                SendInfo items = sendInfos.FirstOrDefault(m => m.FromStoreId == FromStoreId && m.ToStoreId == tostore.Id && m.BrandId == BrandId);
+                if (items == null)
+                {
+                    SendInfo rows = new SendInfo()
+                    {
+                        FromStoreId = FromStoreId,
+                        ToStoreId = tostore.Id,
+                        BrandId = BrandId,
+                        Num = 1
+                    };
+                    sendInfos.Add(rows);
+                }
+                else
+                {
+                    items.Num += 1;
+                }
+            }
+            for (int i = 0; i < ApplyList.Count; i++)
+            {
+                int num = Convert.ToInt32(ApplyList[i]["ApplyNum"].ToString());
+                int BrandIds = Convert.ToInt32(ApplyList[i]["BrandId"].ToString());
+                if (BrandIds == 1) FromStoreId = 7;
+                if (BrandIds == 2) FromStoreId = 721;
+                if (BrandIds == 3) FromStoreId = 697;
+                if (BrandIds == 4) FromStoreId = 774;
+                if (BrandIds == 5) FromStoreId = 775;
+                if (BrandIds == 6) FromStoreId = 871;
+                if (BrandIds == 7) FromStoreId = 1047;
+                if (BrandIds == 8) FromStoreId = 4831;
+                if (BrandIds == 9) FromStoreId = 4832;
+                var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == BrandIds);
+                tostore = db.StoreHouse.FirstOrDefault(m => m.UserId == apply.UserId && m.BrandId == BrandIds.ToString() && m.Status > -1);
+                SendInfo items = sendInfos.FirstOrDefault(m => m.FromStoreId == FromStoreId && m.ToStoreId == tostore.Id && m.BrandId == BrandIds) ?? new SendInfo();
+                if (items.Num > num)
+                {
+                    return "Warning|" + "该条发货记录的" + brandInfo.Name + "发货数量过多!";
+                }
+                if (items.Num < num)
+                {
+                    return "Warning|" + "该条发货记录的" + brandInfo.Name + "发货数量不足!";
+                }
+            }
+
             List<string> PosSnList = new List<string>();
             for (int index = 1; index < list.Count; index++)
             {
@@ -658,7 +732,6 @@ namespace MySystem.Areas.Admin.Controllers
                 {
                     return "总仓无该机具";
                 }
-
             }
 
             foreach (var item in sendInfos)

+ 2 - 2
Areas/Admin/Views/Home/Login.cshtml

@@ -26,11 +26,11 @@
                     <label for="password">密码 / Password</label>
                     <input class="form-input" type="password" name="Pwd" id="Pwd" onKeyUp="if(event.keyCode==13){$('#CheckCode').focus();}" placeholder="请填写密码">
                 </div>
-                <div class="form-group pb10">
+                @* <div class="form-group pb10">
                     <label for="password">验证码 / Verification</label>
                     <input class="form-input" type="text" name="CheckCode" id="CheckCode" onkeyup="if(event.keyCode==13){syslogin();}" placeholder="请填写验证码" style="width: 70%; display: inline-block; margin-right: 2%">
                     <img src="/Api/PublicMethod/CheckCode" onclick="$(this).attr('src','/Api/PublicMethod/CheckCode?r='+Math.random())" style="width: 26%; height:38px;" />
-                </div>
+                </div> *@
                 @*<div class="form-group pb10 cf">
                         <label class="remembermetext fl" for="rememberme">
                             <input type="checkbox" checked name="rememberme">&nbsp;记住我的登录

+ 2 - 2
Startup.cs

@@ -154,11 +154,11 @@ namespace MySystem
         {
             Dictionary<string, Dictionary<string, string>> tables = new Dictionary<string, Dictionary<string, string>>();
             Library.OtherMySqlConn.connstr = Configuration["Setting:SqlConnStr"];
-            System.Data.DataTable tablecollection = Library.OtherMySqlConn.dtable("select DISTINCT TABLE_NAME from information_schema.columns where table_schema = 'KxsMainServer'");
+            System.Data.DataTable tablecollection = Library.OtherMySqlConn.dtable("select DISTINCT TABLE_NAME from information_schema.columns where table_schema = 'KxsMainServer2'");
             foreach (System.Data.DataRow subtable in tablecollection.Rows)
             {
                 Dictionary<string, string> Columns = new Dictionary<string, string>();
-                System.Data.DataTable columncollection = Library.OtherMySqlConn.dtable("select COLUMN_NAME,DATA_TYPE from information_schema.columns where table_schema = 'KxsMainServer' and TABLE_NAME='" + subtable["TABLE_NAME"].ToString() + "'");
+                System.Data.DataTable columncollection = Library.OtherMySqlConn.dtable("select COLUMN_NAME,DATA_TYPE from information_schema.columns where table_schema = 'KxsMainServer2' and TABLE_NAME='" + subtable["TABLE_NAME"].ToString() + "'");
                 foreach (System.Data.DataRow column in columncollection.Rows)
                 {
                     string datatype = column["DATA_TYPE"].ToString();

+ 1 - 1
wwwroot/layuiadmin/modules_main/StoreMachineApply_Admin.js

@@ -170,7 +170,7 @@ layui.config({
                     layero.find('iframe').contents().find('.productlist input[type=hidden][name=BrandId]').each(function (i) {
                         var BrandId = $(this).val();
                         var ApplyNum = ApplyNums.eq(i).val();
-                        SendSn += '{"BrandId":' + BrandId + ',"ApplyNum":' + ApplyNum + '}';
+                        SendSn += '{"ApplyNum":' + ApplyNum + ',"BrandId":' + BrandId + '}';
                         if (i < ApplyNums.length - 1) {
                             SendSn += ',';
                         }