Exemplo n.º 1
0
        public static ResultInfoModel SaveUser(UserModel model, bool isExistAccount)
        {
            var result = new ResultInfoModel();

            result.IsSuccess = _userdal.UpdateUser(model);

            if (!string.IsNullOrWhiteSpace(model.Account) && !isExistAccount)
            {
                var isOrNotExistAccount = _accountDal.GetAccountByAccount(model.Account);
                if (isOrNotExistAccount == null)
                {
                    var account = new AccountModel();
                    account.BAAccount         = model.Account;
                    account.BAPassword        = EncryptHelper.DesEncrypt("123456");
                    account.BAUserId          = model.Id;
                    account.BAType            = UserEnum.Employee.GetHashCode();
                    account.BAIsValid         = EnabledEnum.Enabled.GetHashCode();
                    account.BACreateUserNo    = model.BUOperateUserNo;
                    account.BACreateUserName  = model.BUOperateUserName;
                    account.BACreateTime      = DateTime.Now;
                    account.BAOperateUserNo   = model.BUOperateUserNo;
                    account.BAOperateUserName = model.BUOperateUserName;
                    account.BAOperateTime     = DateTime.Now;
                    _accountDal.InsertAccount(account);
                    result.Code = EncryptHelper.DesEncrypt(model.Id.ToString());
                }
                else
                {
                    result.IsSuccess = false;
                    result.Message   = "Account has exist!";
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public ActionResult Reset(string account, string password)
        {
            var result = new ResultInfoModel {
                IsSuccess = false
            };

            try
            {
                var accontInfo = HomeBusiness.RestAccount(account, password, this.LoginUser);

                var login = HomeBusiness.Login(account, password);

                //写入cookie
                string key  = CommonHelper.Md5(CookieKey.COOKIE_KEY_USERINFO);
                string data = JsonHelper.Serializer <UserLoginInfo>(login);
                CookieHelper.SetCookie(
                    key,
                    CommonHelper.DesEncrypt(data, CookieKey.COOKIE_KEY_ENCRYPT),
                    DateTime.Now.AddDays(1).Date,
                    ServerInfo.GetTopDomain);

                result.IsSuccess = accontInfo.IsSuccess;
                result.Message   = accontInfo.Message;
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            return(Json(result));
        }
Exemplo n.º 3
0
        public static ResultInfoModel SaveDepartment(DepartmentSaveModel model, UserLoginInfo loginUser)
        {
            var result = new ResultInfoModel()
            {
                IsSuccess = true
            };

            try
            {
                var entity = new DepartmentModel()
                {
                    Id                = long.Parse(model.DepartId),
                    BDParentId        = long.Parse(model.ParentId),
                    BDDeptName        = model.DepartName,
                    BDDeptDesc        = model.DepartDesc,
                    BDIsValid         = model.IsValid,
                    BDOperateUserNo   = loginUser.JobNum,
                    BDOperateUserName = loginUser.UserName,
                    BDOperateTime     = DateTime.Now
                };
                _departmentDal.Update(entity);
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Message   = ex.Message;
            }
            return(result);
        }
Exemplo n.º 4
0
        public static ResultInfoModel SaveNewUser(User model)
        {
            var result = new ResultInfoModel();

            if (IfHaveSamePhone(model.BUPhoneNum))
            {
                result.IsSuccess = false;
                result.Message   = "已存在相同手机号的用户";
                return(result);
            }
            if (string.IsNullOrEmpty(model.BUJobNumber) && IfHaveSameJobNumber(model.BUJobNumber))
            {
                result.IsSuccess = false;
                result.Message   = "已存在相同工号的用户";
                return(result);
            }
            var userId = string.Empty;

            try
            {
                using (var tran = SqlHelper.BeginTransaction())
                {
                    userId = EncryptHelper.DesEncrypt(_userdal.InsertUser(model, tran).ToString());
                    var account = new Account();
                    account.BAAccount = "默认账号";
                    account.BAAccount = "123456";
                }
            }
            catch (Exception ex)
            { }

            return(result);
        }
Exemplo n.º 5
0
        public static ResultInfoModel InvalidStandVerification(long id, UserLoginInfo loginUser)
        {
            var returnvalue = new ResultInfoModel()
            {
                IsSuccess = false
            };
            var upParam = new InvalidParam()
            {
                Id          = id,
                JobNum      = loginUser.JobNum,
                Name        = loginUser.UserName,
                InvalidTime = DateTime.Now
            };

            try
            {
                var result = _verificationDal.Invalid(upParam);
                returnvalue.IsSuccess = result;
            }
            catch (Exception ex)
            {
                returnvalue.IsSuccess = false;
                returnvalue.Message   = ex.Message;
            }
            return(returnvalue);
        }
Exemplo n.º 6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            var roleName  = context.Request["roleName"];
            var groupName = context.Request["groupName"];

            var roleInfo  = JurisdictionBusiness.GetRoleByRoleName(roleName);
            var groupInfo = JurisdictionBusiness.GetGroupByGroupName(groupName);
            var result    = new ResultInfoModel {
                IsSuccess = false
            };

            if (roleInfo != null && groupInfo != null)
            {
                result = JurisdictionBusiness.DiRoleToGroup(roleInfo.Id, groupInfo.Id);
            }
            if (result.IsSuccess)
            {
                context.Response.Write("Success");
            }
            else
            {
                context.Response.Write(result.Message);
            }
        }
Exemplo n.º 7
0
        public static ResultInfoModel RestAccount(string account, string password, UserLoginInfo loguser)
        {
            var result = new ResultInfoModel {
                IsSuccess = false,
            };
            //验证账户名是否存在
            var accountInfo = _accountDal.GetAccountByAccount(account);

            if (accountInfo != null && accountInfo.BAPassword == password)
            {
                result.Message = "The password is same with the original password";
                return(result);
            }
            if (accountInfo != null)
            {
                accountInfo.BAPassword        = EncryptHelper.DesEncrypt(password);
                accountInfo.BAOperateUserNo   = loguser.JobNum;
                accountInfo.BAOperateUserName = loguser.UserName;
                accountInfo.BAOperateTime     = DateTime.Now;
                _accountDal.UpdataAccount(accountInfo);
                result.IsSuccess = true;
                result.Message   = "Update Success";
            }
            return(result);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 描述:启用或停用部门
        /// 创建标识:cpf
        /// 创建时间:2017-9-24 18:17:48
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="loginuser"></param>
        /// <returns></returns>
        public static ResultInfoModel UpdateDepartmentValid(string Id, UserLoginInfo loginuser)
        {
            var result = new ResultInfoModel();
            var model  = _departmentDal.GetDpById(Convert.ToInt32(Id));

            if (model != null)
            {
                if (model.BDIsValid == EnabledEnum.Enabled.GetHashCode())
                {
                    var deptlist = _departmentDal.GetDepartmentByParentId(long.Parse(Id));
                    if (deptlist != null && deptlist.Count > 0)
                    {
                        result.IsSuccess = false;
                        result.Message   = "There is an effective sub department under the Department and cannot be deactivated!";
                        return(result);
                    }
                    var userList = _userdal.GetUserListByDeptId(long.Parse(Id));
                    if (userList != null && userList.Count > 0)
                    {
                        result.IsSuccess = false;
                        result.Message   = "You can't disable this department because there are some in-service staff employees under the department!";
                        return(result);
                    }
                    model.BDIsValid         = EnabledEnum.UnEnabled.GetHashCode();
                    model.BDOperateUserNo   = loginuser.JobNum;
                    model.BDOperateUserName = loginuser.UserName;
                    model.BDOperateTime     = DateTime.Now;
                    result.IsSuccess        = _departmentDal.UpdateIsValid(model);
                }
                else
                {
                    var dpInfo = _departmentDal.GetDepartById(Convert.ToInt32(Id));
                    if (!CheckDepartment(dpInfo.Name))
                    {
                        var parentDept = _departmentDal.GetDpById(int.Parse(model.BDParentId.ToString()));
                        if (parentDept != null && parentDept.BDIsValid == EnabledEnum.UnEnabled.GetHashCode())
                        {
                            result.IsSuccess = false;
                            result.Message   = "The higher level has been disabled, so it cannot be enabled";
                            return(result);
                        }
                        model.BDIsValid         = EnabledEnum.Enabled.GetHashCode();
                        model.BDOperateUserNo   = loginuser.JobNum;
                        model.BDOperateUserName = loginuser.UserName;
                        model.BDOperateTime     = DateTime.Now;
                        result.IsSuccess        = _departmentDal.UpdateIsValid(model);
                        result.Code             = EncryptHelper.DesEncrypt(model.BDParentId.ToString());
                    }
                    else
                    {
                        result.IsSuccess = false;
                        result.Message   = dpInfo.Name + "already exists!";
                        return(result);
                    }
                }
                result.Message = "Edit Success";
            }
            return(result);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 描述:启用或停用部门
        /// 创建标识:cpf
        /// 创建时间:2017-9-24 18:17:48
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="loginuser"></param>
        /// <returns></returns>
        public static ResultInfoModel UpdateDepartmentValid(string Id, UserLoginInfo loginuser)
        {
            var result = new ResultInfoModel();
            var model  = _departmentDal.GetDpById(Convert.ToInt32(Id));

            if (model != null)
            {
                if (model.BDIsValid == EnabledEnum.Enabled.GetHashCode())
                {
                    var deptlist = _departmentDal.GetDepartmentByParentId(long.Parse(Id));
                    if (deptlist != null && deptlist.Count > 0)
                    {
                        result.IsSuccess = false;
                        result.Message   = "该部门下存在有效的子部门,不能停用!";
                        return(result);
                    }
                    var userList = _userdal.GetUserListByDeptId(long.Parse(Id));
                    if (userList != null && userList.Count > 0)
                    {
                        result.IsSuccess = false;
                        result.Message   = "该部门下存在在职员工,不能停用!";
                        return(result);
                    }
                    model.BDIsValid         = EnabledEnum.UnEnabled.GetHashCode();
                    model.BDOperateUserId   = int.Parse(loginuser.UserId.ToString());
                    model.BDOperateUserName = loginuser.UserName;
                    model.BDOperateTime     = DateTime.Now;
                    result.IsSuccess        = _departmentDal.UpdateIsValid(model);
                }
                else
                {
                    var dpInfo = _departmentDal.GetDepartById(Convert.ToInt32(Id));
                    if (!CheckDepartment(dpInfo.Name))
                    {
                        var parentDept = _departmentDal.GetDpById(int.Parse(model.BDParentId.ToString()));
                        if (parentDept != null && parentDept.BDIsValid == EnabledEnum.UnEnabled.GetHashCode())
                        {
                            result.IsSuccess = false;
                            result.Message   = "上级部门已停用,故不能启用";
                            return(result);
                        }
                        model.BDIsValid         = EnabledEnum.Enabled.GetHashCode();
                        model.BDOperateUserId   = int.Parse(loginuser.UserId.ToString());
                        model.BDOperateUserName = loginuser.UserName;
                        model.BDOperateTime     = DateTime.Now;
                        result.IsSuccess        = _departmentDal.UpdateIsValid(model);
                        result.Code             = EncryptHelper.DesEncrypt(model.BDParentId.ToString());
                    }
                    else
                    {
                        result.IsSuccess = false;
                        result.Message   = "部门名" + dpInfo.Name + "已存在无法启用!";
                        return(result);
                    }
                }
                result.Message = "编辑成功";
            }
            return(result);
        }
Exemplo n.º 10
0
        public ActionResult UpdateDepartmentValid(string Id)
        {
            var result = new ResultInfoModel();

            if (!string.IsNullOrEmpty(Id))
            {
                result = HomeBusiness.UpdateDepartmentValid(EncryptHelper.DesDecrypt(Id), this.LoginUser);
            }
            return(Json(result));
        }
Exemplo n.º 11
0
        public ActionResult SaveByGroup(string paraStr)
        {
            var model  = JsonHelper.Deserialize <SaveByGroupIdModel>(paraStr);
            var result = new ResultInfoModel {
                IsSuccess = false
            };

            if (model != null)
            {
                result = JurisdictionBusiness.SaveRoleGroupRelationByGroup(model, this.LoginUser);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 12
0
        public static ResultInfoModel SaveNewUser(UserModel model)
        {
            var result = new ResultInfoModel {
                IsSuccess = true
            };

            try
            {
                if (!string.IsNullOrWhiteSpace(model.Account))
                {
                    var isOrNotExistAccount = _accountDal.GetAccountByAccount(model.Account);
                    if (isOrNotExistAccount == null)
                    {
                        var userId  = _userdal.InsertUser(model);
                        var account = new AccountModel();
                        account.BAAccount         = model.Account;
                        account.BAPassword        = EncryptHelper.DesEncrypt("123456");
                        account.BAUserId          = int.Parse(userId.ToString());
                        account.BAType            = UserEnum.Employee.GetHashCode();
                        account.BAIsValid         = EnabledEnum.Enabled.GetHashCode();
                        account.BACreateUserNo    = model.BUCreateUserNo;
                        account.BACreateUserName  = model.BUCreateUserName;
                        account.BACreateTime      = DateTime.Now;
                        account.BAOperateUserNo   = model.BUOperateUserNo;
                        account.BAOperateUserName = model.BUOperateUserName;
                        account.BAOperateTime     = DateTime.Now;
                        _accountDal.InsertAccount(account);
                        result.Code = EncryptHelper.DesEncrypt(userId.ToString());
                    }
                    else
                    {
                        result.IsSuccess = false;
                        result.Message   = "Account has exist!";
                    }
                }
                else
                {
                    var userId = _userdal.InsertUser(model);
                    result.Code = EncryptHelper.DesEncrypt(userId.ToString());
                }
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Message   = ex.Message;
            }
            return(result);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 描述:重置用户密码
        /// </summary>
        /// <param name="userid">用户Id</param>
        /// <returns></returns>
        public ActionResult RestPassByUserid(string userId)
        {
            var result = new ResultInfoModel {
                IsSuccess = false
            };

            try
            {
                result = HomeBusiness.RestAccountByUserid(userId, LoginUser);
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            return(Json(result));
        }
Exemplo n.º 14
0
 private void SetDetectedItemsToBindableItems(List <DetectedItemInfo> items)
 {
     m_ResultViewModel.ResultModelList.Clear();
     foreach (DetectedItemInfo item in items)
     {
         ResultInfoModel resultModel = new ResultInfoModel();
         resultModel.DetectionLabel      = item.Type;
         resultModel.Confidence          = item.Confidence;
         resultModel.DetectedBoxLeftTopX = item.X;
         resultModel.DetectedBoxLeftTopY = item.Y;
         resultModel.DetectedBoxWidth    = item.Width;
         resultModel.DetectedBoxHeight   = item.Height;
         m_ResultViewModel.ResultModelList.Add(resultModel);
     }
     DrawBoundingBox(items);
 }
Exemplo n.º 15
0
        /// <summary>
        /// 描述:根据用户id初始化用户密码
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static ResultInfoModel RestAccountByUserid(string userId, UserLoginInfo loguser)
        {
            var result = new ResultInfoModel {
                IsSuccess = false,
            };
            var accountInfo = _accountDal.GetAccountByUserId(long.Parse(EncryptHelper.DesDecrypt(userId)));

            if (accountInfo != null)
            {
                accountInfo.BAPassword        = EncryptHelper.DesEncrypt(ConfigurationManager.AppSettings["defaultPassword"].ToString());
                accountInfo.BAOperateUserNo   = loguser.JobNum;
                accountInfo.BAOperateUserName = loguser.UserName;
                accountInfo.BAOperateTime     = DateTime.Now;
                _accountDal.UpdataAccount(accountInfo);
                result.IsSuccess = true;
                result.Message   = "Update Success";
            }
            return(result);
        }
Exemplo n.º 16
0
        /// <summary>
        /// 描述:保存新部门
        /// 创建标识:cpf
        /// 创建时间:2017-9-21 21:56:37
        /// </summary>
        /// <param name="model"></param>
        /// <param name="loginUser"></param>
        /// <returns></returns>
        public static ResultInfoModel SaveNewDepartment(DepartmentSaveModel model, UserLoginInfo loginUser)
        {
            var result = new ResultInfoModel()
            {
                IsSuccess = true
            };
            var flag = CheckDepartment(model.DepartName);

            try
            {
                if (!flag)
                {
                    var entity = new DepartmentModel()
                    {
                        BDParentId        = long.Parse(model.ParentId),
                        BDDeptName        = model.DepartName,
                        BDDeptDesc        = model.DepartDesc ?? string.Empty,
                        BDIsValid         = model.IsValid,
                        BDCreateUserNo    = loginUser.JobNum,
                        BDCreateUserName  = loginUser.UserName,
                        BDCreateTime      = DateTime.Now,
                        BDOperateUserNo   = loginUser.JobNum,
                        BDOperateUserName = loginUser.UserName,
                        BDOperateTime     = DateTime.Now
                    };
                    var ids = _departmentDal.Insert(entity);
                    result.Code = EncryptHelper.DesEncrypt(ids.ToString());
                }
                else
                {
                    result.IsSuccess = false;
                    result.Message   = "A department with the same name already exists";
                }
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Message   = ex.Message;
            }
            return(result);
        }
Exemplo n.º 17
0
        /// <summary>
        /// 描述:保存新部门
        /// 创建标识:cpf
        /// 创建时间:2017-9-21 21:56:37
        /// </summary>
        /// <param name="model"></param>
        /// <param name="loginUser"></param>
        /// <returns></returns>
        public static ResultInfoModel SaveNewDepartment(DepartmentSaveModel model, UserLoginInfo loginUser)
        {
            var result = new ResultInfoModel()
            {
                IsSuccess = true
            };
            var flag = CheckDepartment(model.DepartName);

            try
            {
                if (!flag)
                {
                    var entity = new Department()
                    {
                        BDParentId        = long.Parse(model.ParentId),
                        BDDeptName        = model.DepartName,
                        BDDeptDescription = model.DepartDesc,
                        BDIsValid         = model.IsValid,
                        BDCreateUserId    = Convert.ToInt32(loginUser.UserId),
                        BDCreateUserName  = loginUser.UserName,
                        BDCreateTime      = DateTime.Now,
                        BDOperateUserId   = Convert.ToInt32(loginUser.UserId),
                        BDOperateUserName = loginUser.UserName,
                        BDOperateTime     = DateTime.Now
                    };
                    var ids = _departmentDal.Insert(entity);
                    result.Code = EncryptHelper.DesEncrypt(ids.ToString());
                }
                else
                {
                    result.IsSuccess = false;
                    result.Message   = "已存在相同名称的部门";
                }
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Message   = ex.Message;
            }
            return(result);
        }
Exemplo n.º 18
0
        private void ResultsDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ResultInfoModel resultModel = ResultsDataGrid.SelectedItem as ResultInfoModel;

            if (resultModel == null)
            {
                return;
            }

            DetectedItemInfo item = new DetectedItemInfo();

            item.Type       = resultModel.DetectionLabel;
            item.Confidence = resultModel.Confidence;
            item.X          = resultModel.DetectedBoxLeftTopX;
            item.Y          = resultModel.DetectedBoxLeftTopY;
            item.Width      = resultModel.DetectedBoxWidth;
            item.Height     = resultModel.DetectedBoxHeight;

            PreviewImageModel previewModel = PreviewImageModel.Instance;

            previewModel.DrawDetectedBoundingBoxOnImage(item);
        }
Exemplo n.º 19
0
        public ActionResult UsrSave(UserView model)
        {
            var result = new ResultInfoModel();

            try
            {
                if (string.IsNullOrEmpty(model.UserId))
                {
                    //新增
                    var user = new User();
                    user.BUSurname         = model.BUSurname;
                    user.BUGivenname       = model.BUGivenname;
                    user.BUJobNumber       = model.BUJobNumber;
                    user.BUSex             = model.BUSex;
                    user.BUAvatars         = model.BUAvatars;
                    user.BUPhoneNum        = model.BUPhoneNum;
                    user.BUEmail           = model.BUEmail;
                    user.BUDepartId        = int.Parse(EncryptHelper.DesDecrypt(model.DepartId));
                    user.BUTitle           = model.BUTitle;
                    user.BUIsValid         = model.BUIsValid;
                    user.BUCreateUserId    = int.Parse(LoginUser.UserId.ToString());
                    user.BUCreateUserName  = LoginUser.UserName;
                    user.BUCreateTime      = DateTime.Now;
                    user.BUOperateUserId   = int.Parse(LoginUser.UserId.ToString());
                    user.BUOperateUserName = LoginUser.UserName;
                    user.BUOperateTime     = DateTime.Now;
                    result = HomeBusiness.SaveNewUser(user);
                }
                else
                {
                    //解密id
                }
            }
            catch (Exception ex)
            {
            }
            return(Json(new { }));
        }
Exemplo n.º 20
0
        public static ResultInfoModel InitialData()
        {
            var result = new ResultInfoModel {
                IsSuccess = false
            };

            using (var con = new SqlConnection(NewSqlHelper.ConnectionString))
            {
                con.Open();
                var tran = con.BeginTransaction();
                try
                {
                    var now   = DateTime.Now;
                    var code1 = new CodeModel
                    {
                        BCCode            = "Assembling",
                        BCCodeDesc        = "Assembling",
                        BCCategory        = "ProblemProcess",
                        BCCodeOrder       = 1,
                        BCIsValid         = EnabledEnum.Enabled.GetHashCode(),
                        BCCreateUserNo    = "00000",
                        BCCreateUserName  = "******",
                        BCCreateTime      = now,
                        BCOperateUserNo   = "00000",
                        BCOperateUserName = "******",
                        BCOperateTime     = now
                    };
                    _codeDAL.InsertModel(code1);
                    var code2 = new CodeModel
                    {
                        BCCode            = "Molding",
                        BCCodeDesc        = "Molding",
                        BCCategory        = "ProblemProcess",
                        BCCodeOrder       = 2,
                        BCIsValid         = EnabledEnum.Enabled.GetHashCode(),
                        BCCreateUserNo    = "00000",
                        BCCreateUserName  = "******",
                        BCCreateTime      = now,
                        BCOperateUserNo   = "00000",
                        BCOperateUserName = "******",
                        BCOperateTime     = now
                    };
                    _codeDAL.InsertModel(code2);
                    var code3 = new CodeModel
                    {
                        BCCode            = "Press Molding",
                        BCCodeDesc        = "Press Molding",
                        BCCategory        = "ProblemProcess",
                        BCCodeOrder       = 3,
                        BCIsValid         = EnabledEnum.Enabled.GetHashCode(),
                        BCCreateUserNo    = "00000",
                        BCCreateUserName  = "******",
                        BCCreateTime      = now,
                        BCOperateUserNo   = "00000",
                        BCOperateUserName = "******",
                        BCOperateTime     = now
                    };
                    _codeDAL.InsertModel(code3);
                    var code4 = new CodeModel
                    {
                        BCCode            = "3D Blow Molding",
                        BCCodeDesc        = "3D Blow Molding",
                        BCCategory        = "ProblemProcess",
                        BCCodeOrder       = 4,
                        BCIsValid         = EnabledEnum.Enabled.GetHashCode(),
                        BCCreateUserNo    = "00000",
                        BCCreateUserName  = "******",
                        BCCreateTime      = now,
                        BCOperateUserNo   = "00000",
                        BCOperateUserName = "******",
                        BCOperateTime     = now
                    };
                    _codeDAL.InsertModel(code4);
                    var code5 = new CodeModel
                    {
                        BCCode            = "3D Blow Assembling",
                        BCCodeDesc        = "3D Blow Assembling",
                        BCCategory        = "ProblemProcess",
                        BCCodeOrder       = 5,
                        BCIsValid         = EnabledEnum.Enabled.GetHashCode(),
                        BCCreateUserNo    = "00000",
                        BCCreateUserName  = "******",
                        BCCreateTime      = now,
                        BCOperateUserNo   = "00000",
                        BCOperateUserName = "******",
                        BCOperateTime     = now
                    };
                    _codeDAL.InsertModel(code5);
                    var code6 = new CodeModel
                    {
                        BCCode            = "Foaming",
                        BCCodeDesc        = "Foaming",
                        BCCategory        = "ProblemProcess",
                        BCCodeOrder       = 6,
                        BCIsValid         = EnabledEnum.Enabled.GetHashCode(),
                        BCCreateUserNo    = "00000",
                        BCCreateUserName  = "******",
                        BCCreateTime      = now,
                        BCOperateUserNo   = "00000",
                        BCOperateUserName = "******",
                        BCOperateTime     = now
                    };
                    _codeDAL.InsertModel(code6);
                    var code7 = new CodeModel
                    {
                        BCCode            = "Other",
                        BCCodeDesc        = "Other",
                        BCCategory        = "ProblemProcess",
                        BCCodeOrder       = 7,
                        BCIsValid         = EnabledEnum.Enabled.GetHashCode(),
                        BCCreateUserNo    = "00000",
                        BCCreateUserName  = "******",
                        BCCreateTime      = now,
                        BCOperateUserNo   = "00000",
                        BCOperateUserName = "******",
                        BCOperateTime     = now
                    };
                    _codeDAL.InsertModel(code7);
                    var code8 = new CodeModel
                    {
                        BCCode            = "All",
                        BCCodeDesc        = "All",
                        BCCategory        = "ProblemProcess",
                        BCCodeOrder       = 8,
                        BCIsValid         = EnabledEnum.Enabled.GetHashCode(),
                        BCCreateUserNo    = "00000",
                        BCCreateUserName  = "******",
                        BCCreateTime      = now,
                        BCOperateUserNo   = "00000",
                        BCOperateUserName = "******",
                        BCOperateTime     = now
                    };
                    _codeDAL.InsertModel(code8);

                    var code21 = new CodeModel
                    {
                        BCCode            = "Customer Complaint",
                        BCCodeDesc        = "Customer Complaint",
                        BCCategory        = "ProblemSource",
                        BCCodeOrder       = 1,
                        BCIsValid         = EnabledEnum.Enabled.GetHashCode(),
                        BCCreateUserNo    = "00000",
                        BCCreateUserName  = "******",
                        BCCreateTime      = now,
                        BCOperateUserNo   = "00000",
                        BCOperateUserName = "******",
                        BCOperateTime     = now
                    };
                    _codeDAL.InsertModel(code21);

                    var code22 = new CodeModel
                    {
                        BCCode            = "Production",
                        BCCodeDesc        = "Production",
                        BCCategory        = "ProblemSource",
                        BCCodeOrder       = 2,
                        BCIsValid         = EnabledEnum.Enabled.GetHashCode(),
                        BCCreateUserNo    = "00000",
                        BCCreateUserName  = "******",
                        BCCreateTime      = now,
                        BCOperateUserNo   = "00000",
                        BCOperateUserName = "******",
                        BCOperateTime     = now
                    };
                    _codeDAL.InsertModel(code22);

                    var code23 = new CodeModel
                    {
                        BCCode            = "Supplier",
                        BCCodeDesc        = "Supplier",
                        BCCategory        = "ProblemSource",
                        BCCodeOrder       = 3,
                        BCIsValid         = EnabledEnum.Enabled.GetHashCode(),
                        BCCreateUserNo    = "00000",
                        BCCreateUserName  = "******",
                        BCCreateTime      = now,
                        BCOperateUserNo   = "00000",
                        BCOperateUserName = "******",
                        BCOperateTime     = now
                    };
                    _codeDAL.InsertModel(code23);

                    var code24 = new CodeModel
                    {
                        BCCode            = "Equipment",
                        BCCodeDesc        = "Equipment",
                        BCCategory        = "ProblemSource",
                        BCCodeOrder       = 4,
                        BCIsValid         = EnabledEnum.Enabled.GetHashCode(),
                        BCCreateUserNo    = "00000",
                        BCCreateUserName  = "******",
                        BCCreateTime      = now,
                        BCOperateUserNo   = "00000",
                        BCOperateUserName = "******",
                        BCOperateTime     = now
                    };
                    _codeDAL.InsertModel(code24);
                    var code25 = new CodeModel
                    {
                        BCCode            = "Tooling",
                        BCCodeDesc        = "Tooling",
                        BCCategory        = "ProblemSource",
                        BCCodeOrder       = 5,
                        BCIsValid         = EnabledEnum.Enabled.GetHashCode(),
                        BCCreateUserNo    = "00000",
                        BCCreateUserName  = "******",
                        BCCreateTime      = now,
                        BCOperateUserNo   = "00000",
                        BCOperateUserName = "******",
                        BCOperateTime     = now
                    };
                    _codeDAL.InsertModel(code25);
                }
                catch (Exception ex)
                {
                    result.Message = ex.Message;
                }
            }
            return(result);
        }
Exemplo n.º 21
0
        public ActionResult UpLoadFile()
        {
            var result = new ResultInfoModel()
            {
                IsSuccess = false
            };
            StringBuilder      strbuild = new StringBuilder();
            string             FileName;
            string             savePath;
            HttpPostedFileBase file = Request.Files["file"];

            if (file == null || file.ContentLength <= 0)
            {
                result.Message = "please choose file";
                return(Content(JsonHelper.JsonSerializer(result)));
            }
            else
            {
                string fileName   = Path.GetFileName(file.FileName);
                int    filesize   = file.ContentLength;                         //获取上传文件的大小单位为字节byte
                string fileEx     = Path.GetExtension(fileName);                //获取上传文件的扩展名
                string NoFileName = Path.GetFileNameWithoutExtension(fileName); //获取无扩展名的文件名
                int    Maxsize    = 4000 * 1024;                                //定义上传文件的最大空间大小为4M
                string FileType   = ".xls,.xlsx";                               //定义上传文件的类型字符串

                FileName = NoFileName + fileEx;
                if (!FileType.Contains(fileEx))
                {
                    result.Message = "please upload .xls and .xlsx";
                    return(Content(JsonHelper.JsonSerializer(result)));
                }
                if (filesize >= Maxsize)
                {
                    result.Message = string.Format("file size can't big than {0}", Maxsize);
                    return(Content(JsonHelper.JsonSerializer(result)));
                }
                string path = Server.MapPath("~/App_Data/uploads");
                savePath = Path.Combine(path, FileName);
                file.SaveAs(savePath);
            }

            string strConn;

            strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + savePath + ";Extended Properties=Excel 12.0;";
            using (OleDbConnection conn = new OleDbConnection(strConn))
            {
                conn.Open();
                OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [Sheet1$]", strConn);
                DataSet          myDataSet = new DataSet();
                try
                {
                    myCommand.Fill(myDataSet, "ExcelInfo");
                }
                catch (Exception ex)
                {
                    result.Message = ex.Message;
                    return(Content(JsonHelper.JsonSerializer(result)));
                }
                DataTable table = myDataSet.Tables["ExcelInfo"].DefaultView.ToTable();

                try
                {
                    var maxJobNumber = string.Empty;
                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        var model = new UserModel();
                        model.BUName            = table.Rows[i]["ChineseName"].ToString() ?? "";
                        model.BUSex             = 0;
                        model.BUAvatars         = string.Empty;
                        model.BUPhoneNum        = table.Rows[i]["PhoneNum"].ToString() ?? "";
                        model.BUEmail           = table.Rows[i]["Email"].ToString() ?? "";
                        model.BUDepartId        = 0;
                        model.BUTitle           = string.Empty;
                        model.BUIsValid         = EnabledEnum.Enabled.GetHashCode();
                        model.BUCreateUserNo    = LoginUser.JobNum;
                        model.BUCreateUserName  = LoginUser.UserName;
                        model.BUCreateTime      = DateTime.Now;
                        model.BUOperateUserNo   = LoginUser.JobNum;
                        model.BUOperateUserName = LoginUser.UserName;
                        model.BUOperateTime     = DateTime.Now;
                        model.BUDepartName      = table.Rows[i]["DepartName"].ToString() ?? "";
                        model.BUExtensionPhone  = table.Rows[i]["ExtensionPhone"].ToString() ?? "";
                        model.BUEnglishName     = table.Rows[i]["EnglishName"].ToString() ?? "";
                        model.BUPosition        = table.Rows[i]["Position"].ToString() ?? "";
                        model.BUMobilePhone     = table.Rows[i]["MobilePhone"].ToString() ?? "";
                        model.Account           = table.Rows[i]["Account"].ToString() ?? "";
                        maxJobNumber            = HomeBusiness.GenerateNewJobNumber(maxJobNumber);
                        model.BUJobNumber       = maxJobNumber;


                        var inserResult = HomeBusiness.SaveNewUser(model);
                    }
                    result.IsSuccess = true;
                }
                catch (Exception ex)
                {
                    result.Message = ex.Message;
                    return(Content(JsonHelper.JsonSerializer(result)));
                }
                conn.Close();
            }
            return(Content(JsonHelper.JsonSerializer(result)));
        }
Exemplo n.º 22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult UsrSave(UserView model)
        {
            var result = new ResultInfoModel
            {
                IsSuccess = true
            };

            try
            {
                if (string.IsNullOrEmpty(model.UserId) || model.UserId.Equals("0"))
                {
                    //新增
                    var user = new UserModel();
                    user.BUName = model.BUName;
                    user.BUSex  = model.BUSex;
                    if (!string.IsNullOrWhiteSpace(model.BUAvatars))
                    {
                        var path = model.BUAvatars.Substring(ServerInfo.RootURI.Length);
                        user.BUAvatars = path;
                    }
                    else
                    {
                        user.BUAvatars = string.Empty;
                    }
                    user.BUPhoneNum = model.BUPhoneNum;
                    user.BUEmail    = model.BUEmail;
                    //user.BUDepartId = int.Parse(EncryptHelper.DesDecrypt(model.DepartId));
                    user.BUTitle           = model.BUTitle;
                    user.BUIsValid         = model.BUIsValid;
                    user.BUCreateUserNo    = LoginUser.JobNum;
                    user.BUCreateUserName  = LoginUser.UserName;
                    user.BUCreateTime      = DateTime.Now;
                    user.BUOperateUserNo   = LoginUser.JobNum;;
                    user.BUOperateUserName = LoginUser.UserName;
                    user.BUOperateTime     = DateTime.Now;

                    user.BUDepartName     = model.BUDepartName;
                    user.BUExtensionPhone = model.BUExtensionPhone;
                    user.BUEnglishName    = model.BUEnglishName;
                    user.BUPosition       = model.BUPosition;
                    user.BUMobilePhone    = model.BUMobilePhone;
                    user.BUJobNumber      = HomeBusiness.GenerateNewJobNumber(string.Empty);
                    user.Account          = model.Account;
                    result = HomeBusiness.SaveNewUser(user);
                }
                else
                {
                    //解密id
                    model.UserId = EncryptHelper.DesDecrypt(model.UserId);
                    var user = HomeBusiness.GetUserById(long.Parse(model.UserId));
                    user.BUName     = model.BUName;
                    user.BUSex      = model.BUSex;
                    user.BUAvatars  = model.BUAvatars;
                    user.BUPhoneNum = model.BUPhoneNum;
                    user.BUEmail    = model.BUEmail;
                    //user.BUDepartId = int.Parse(EncryptHelper.DesDecrypt(model.DepartId));
                    user.BUTitle           = model.BUTitle;
                    user.BUIsValid         = model.BUIsValid;
                    user.BUOperateUserNo   = LoginUser.JobNum;
                    user.BUOperateUserName = LoginUser.UserName;
                    //user.BUOperateUserNo = "33029";
                    //user.BUOperateUserName = "******";
                    user.BUOperateTime    = DateTime.Now;
                    user.BUDepartName     = model.BUDepartName;
                    user.BUExtensionPhone = model.BUExtensionPhone;
                    user.BUEnglishName    = model.BUEnglishName;
                    user.BUPosition       = model.BUPosition;
                    user.BUMobilePhone    = model.BUMobilePhone;
                    user.Account          = model.Account;
                    var isExistAccount = model.IsExistAccount;
                    result = HomeBusiness.SaveUser(user, isExistAccount);
                }
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Message   = ex.Message;
            }
            return(Json(result));
        }
Exemplo n.º 23
0
        /// <summary>
        /// Test
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public ActionResult UploadMaterialFiles()
        {
            var result = new ResultInfoModel()
            {
                IsSuccess = false
            };
            StringBuilder      strbuild = new StringBuilder();
            string             FileName;
            string             savePath;
            HttpPostedFileBase file = Request.Files["file"];

            if (file == null || file.ContentLength <= 0)
            {
                result.Message = "please choose file";
                return(Content(JsonHelper.JsonSerializer(result)));
            }
            else
            {
                string fileName   = Path.GetFileName(file.FileName);
                int    filesize   = file.ContentLength;                         //获取上传文件的大小单位为字节byte
                string fileEx     = Path.GetExtension(fileName);                //获取上传文件的扩展名
                string NoFileName = Path.GetFileNameWithoutExtension(fileName); //获取无扩展名的文件名
                int    Maxsize    = 4000 * 1024;                                //定义上传文件的最大空间大小为4M
                string FileType   = ".xls,.xlsx";                               //定义上传文件的类型字符串

                FileName = NoFileName + fileEx;
                if (!FileType.Contains(fileEx))
                {
                    result.Message = "please upload .xls and .xlsx";
                    return(Content(JsonHelper.JsonSerializer(result)));
                }
                if (filesize >= Maxsize)
                {
                    result.Message = string.Format("file size can't big than {0}", Maxsize);
                    return(Content(JsonHelper.JsonSerializer(result)));
                }
                string path = Server.MapPath("~/App_Data/uploads");
                savePath = Path.Combine(path, FileName);
                file.SaveAs(savePath);


                string strConn;
                strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + savePath + ";Extended Properties=Excel 12.0;";
                using (OleDbConnection conn = new OleDbConnection(strConn))
                {
                    conn.Open();
                    OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [Sheet1$]", strConn);
                    DataSet          myDataSet = new DataSet();
                    try
                    {
                        myCommand.Fill(myDataSet, "ExcelInfo");
                    }
                    catch (Exception ex)
                    {
                        result.Message = ex.Message;
                        return(Content(JsonHelper.JsonSerializer(result)));
                    }
                    DataTable table = myDataSet.Tables["ExcelInfo"].DefaultView.ToTable();
                    try
                    {
                        for (int i = 0; i < table.Rows.Count; i++)
                        {
                            MaterialInfoModel model = new MaterialInfoModel();
                            model.MIProcessType = table.Rows[i][0].ToString();
                            model.MICustomer    = table.Rows[i][1].ToString();
                            model.MISapPN       = table.Rows[i][2].ToString();

                            model.MIProductName = table.Rows[i][3].ToString();
                            model.MIInjectionMC = table.Rows[i][4].ToString();
                            model.MICustomerPN  = table.Rows[i][5].ToString();

                            model.MICavity            = DataConvertHelper.ToInt(table.Rows[i][6].ToString(), 0);
                            model.MICycletime         = DataConvertHelper.ToDecimal(table.Rows[i][7].ToString(), 0);
                            model.MICycletimeCav      = DataConvertHelper.ToDecimal(table.Rows[i][8].ToString(), 0);
                            model.MIStandardHeadcount = DataConvertHelper.ToInt(table.Rows[i][9].ToString(), 0);
                            model.MTStandardScrap     = table.Rows[i][10].ToString();
                            model.MIMaterialPN        = table.Rows[i][11].ToString();
                            model.MICavityG           = DataConvertHelper.ToDecimal(table.Rows[i][12].ToString(), 0);
                            model.MIMoldNo            = table.Rows[i][13].ToString();
                            model.MIAssAC             = table.Rows[i][14].ToString();
                            model.MIWorkOrder         = table.Rows[i][15].ToString();
                            MaterialBusiness.SaveMaterial(model, this.LoginUser);
                            var insertResult = MaterialBusiness.SaveMaterial(model, LoginUser);
                        }
                        result.IsSuccess = true;
                    }
                    catch (Exception ex)
                    {
                        result.Message = ex.Message;
                        return(Content(JsonHelper.JsonSerializer(result)));
                    }
                    conn.Close();
                }
                return(Content(JsonHelper.JsonSerializer(result)));
            }
        }
Exemplo n.º 24
0
        public ActionResult ImportWorkOrder(int type)
        {
            var result = new ResultInfoModel()
            {
                IsSuccess = false
            };
            StringBuilder      strbuild = new StringBuilder();
            string             FileName;
            string             savePath;
            HttpPostedFileBase file = Request.Files["file"];

            if (file == null || file.ContentLength <= 0)
            {
                result.Message = "please choose file";
                return(Content(JsonHelper.JsonSerializer(result)));
            }
            else
            {
                string fileName   = Path.GetFileName(file.FileName);
                int    filesize   = file.ContentLength;                         //获取上传文件的大小单位为字节byte
                string fileEx     = Path.GetExtension(fileName);                //获取上传文件的扩展名
                string NoFileName = Path.GetFileNameWithoutExtension(fileName); //获取无扩展名的文件名
                int    Maxsize    = 4000 * 1024;                                //定义上传文件的最大空间大小为4M
                string FileType   = ".xls,.xlsx";                               //定义上传文件的类型字符串

                FileName = NoFileName + fileEx;
                if (!FileType.Contains(fileEx))
                {
                    result.Message = "please upload .xls and .xlsx";
                    return(Content(JsonHelper.JsonSerializer(result)));
                }
                if (filesize >= Maxsize)
                {
                    result.Message = string.Format("file size can't big than {0}", Maxsize);
                    return(Content(JsonHelper.JsonSerializer(result)));
                }
                string path = Server.MapPath("~/App_Data/uploads");
                savePath = Path.Combine(path, FileName);
                file.SaveAs(savePath);


                string strConn;
                strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + savePath + ";Extended Properties=Excel 12.0;";
                using (OleDbConnection conn = new OleDbConnection(strConn))
                {
                    conn.Open();
                    OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [Sheet1$]", strConn);
                    DataSet          myDataSet = new DataSet();
                    try
                    {
                        myCommand.Fill(myDataSet, "ExcelInfo");
                    }
                    catch (Exception ex)
                    {
                        result.Message = ex.Message;
                        return(Content(JsonHelper.JsonSerializer(result)));
                    }
                    DataTable table = myDataSet.Tables["ExcelInfo"].DefaultView.ToTable();
                    try
                    {
                        for (int i = 0; i < table.Rows.Count; i++)
                        {
                            WorkOrderInfo model = new WorkOrderInfo();
                            model.WIWorkOrder             = table.Rows[i][0].ToString();
                            model.WISapPN                 = table.Rows[i][1].ToString();
                            model.WIProductName           = table.Rows[i][2].ToString();
                            model.WIReceiptTime           = table.Rows[i][3].ToString();
                            model.WIReceiptBy             = table.Rows[i][4].ToString();
                            model.WICloseDateShift        = table.Rows[i][5].ToString();
                            model.WIOrderArchived         = table.Rows[i][6].ToString();
                            model.WIParameterRecord       = table.Rows[i][7].ToString();
                            model.WIToolMaintenanceRecord = table.Rows[i][8].ToString();
                            model.WIToolMachineCheck      = table.Rows[i][9].ToString();
                            model.WIQuantityConfirm       = table.Rows[i][10].ToString();
                            model.WIArchivedBy            = table.Rows[i][11].ToString();
                            model.WIWeeklyCheck           = table.Rows[i][12].ToString();
                            model.WIRemarks               = table.Rows[i][7].ToString();
                            model.WIGetBy                 = table.Rows[i][8].ToString();
                            model.WIGetTime               = table.Rows[i][9].ToString();
                            model.WIType = type;
                            MaterialBusiness.SaveWorkOrder(model, this.LoginUser);
                        }
                        result.IsSuccess = true;
                    }
                    catch (Exception ex)
                    {
                        result.Message = ex.Message;
                        return(Content(JsonHelper.JsonSerializer(result)));
                    }
                    conn.Close();
                }
                return(Content(JsonHelper.JsonSerializer(result)));
            }
        }
Exemplo n.º 25
0
        public ActionResult UploadDefectCodeFiles()
        {
            var result = new ResultInfoModel()
            {
                IsSuccess = false
            };
            StringBuilder      strbuild = new StringBuilder();
            string             FileName;
            string             savePath;
            HttpPostedFileBase file = Request.Files["file"];

            if (file == null || file.ContentLength <= 0)
            {
                result.Message = "please choose file";
                return(Content(JsonHelper.JsonSerializer(result)));
            }
            else
            {
                string fileName   = Path.GetFileName(file.FileName);
                int    filesize   = file.ContentLength;                         //获取上传文件的大小单位为字节byte
                string fileEx     = Path.GetExtension(fileName);                //获取上传文件的扩展名
                string NoFileName = Path.GetFileNameWithoutExtension(fileName); //获取无扩展名的文件名
                int    Maxsize    = 5000 * 1024;                                //定义上传文件的最大空间大小为4M
                string FileType   = ".xls,.xlsx";                               //定义上传文件的类型字符串

                FileName = NoFileName + fileEx;
                if (!FileType.Contains(fileEx))
                {
                    result.Message = "please upload .xls and .xlsx";
                    return(Content(JsonHelper.JsonSerializer(result)));
                }
                if (filesize >= Maxsize)
                {
                    result.Message = string.Format("file size can't big than {0}", Maxsize);
                    return(Content(JsonHelper.JsonSerializer(result)));
                }
                string path = Server.MapPath("~/App_Data/uploads");
                savePath = Path.Combine(path, FileName);
                file.SaveAs(savePath);

                string strConn;
                strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + savePath + ";Extended Properties=Excel 12.0;";
                using (OleDbConnection conn = new OleDbConnection(strConn))
                {
                    conn.Open();
                    OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [Sheet1$]", strConn);
                    DataSet          myDataSet = new DataSet();
                    try
                    {
                        myCommand.Fill(myDataSet, "ExcelInfo");
                    }
                    catch (Exception ex)
                    {
                        result.Message = ex.Message;
                        return(Content(JsonHelper.JsonSerializer(result)));
                    }
                    DataTable table = myDataSet.Tables["ExcelInfo"].DefaultView.ToTable();

                    var importResult = new Importresult();
                    importResult.FalseInfo = new List <FalseInfo>();

                    try
                    {
                        for (int i = 0; i < table.Rows.Count; i++)
                        {
                            CodeDefectModel model = new CodeDefectModel();
                            model.BDCodeType   = table.Rows[i][0].ToString();
                            model.BDCodeNo     = DataConvertHelper.ToInt(table.Rows[i][1].ToString(), 0);
                            model.BDCode       = table.Rows[i][2].ToString();
                            model.BDCodeNameEn = table.Rows[i][3].ToString();
                            model.BDCodeNameCn = table.Rows[i][4].ToString();
                            var inserResult = CodeBusiness.SaveDefectCode(model, this.LoginUser);
                        }
                        result.IsSuccess = true;
                    }
                    catch (Exception ex)
                    {
                        result.Message = ex.Message;
                        return(Content(JsonHelper.JsonSerializer(result)));
                    }
                    conn.Close();
                }
            }
            return(Content(JsonHelper.JsonSerializer(result)));
        }