public JsonResult Save(string positionId)
        {
            try
            {
                if (!IsSavePermission(positionId))
                {
                    return(Error("您没有操作权限,请联系系统管理员!"));
                }

                string fPositionId   = GetFormValue("fPositionId");
                string fPositionName = GetFormValue("fPositionName");
                string fSort         = GetFormValue("fSort");
                string fDescription  = GetFormValue("fDescription");
                string fState        = GetFormValue("fState");

                if (string.IsNullOrEmpty(positionId))
                {
                    if (string.IsNullOrWhiteSpace(fPositionId))
                    {
                        return(Error("职位编号不能为空!"));
                    }
                    else
                    {
                        if (fPositionId.Length > 6)
                        {
                            return(Error("职位编号必是6位数字!"));
                        }
                    }
                    fPositionId = fPositionId.PadLeft(6, '0');
                }
                int  sort   = fSort.ToInt();
                bool state  = fState.ToBool();
                bool result = false;
                if (string.IsNullOrEmpty(positionId))
                {
                    result = PositionService.SavePositionPro(SystemID, CompanyID, fPositionId, fPositionName, fDescription, sort, state);
                    var entity = PositionService.GetPositionPro(SystemID, CompanyID, fPositionId);
                    TableOperationManager.Add(entity, result);
                }
                else
                {
                    var entity = PositionService.GetPositionPro(SystemID, CompanyID, positionId);
                    result = PositionService.UpdatePositionPro(SystemID, CompanyID, positionId, fPositionName, fDescription, sort, state);
                    string newEntityJson = GetNewEntityJson(entity, fPositionName, fDescription, sort, state);
                    TableOperationManager.Update(entity, newEntityJson, result);
                }
                if (result)
                {
                    return(Success("ok"));
                }
                else
                {
                    return(Error("fail"));
                }
            }
            catch (Exception ex)
            {
                return(Error(ex.Message));
            }
        }
예제 #2
0
        public JsonResult Save(string rankId)
        {
            try
            {
                if (!IsSavePermission(rankId))
                {
                    return(Error("您没有操作权限,请联系系统管理员!"));
                }

                string fRankName  = GetFormValue("fRankName");
                string fMaxPoints = GetFormValue("fMaxPoints");
                string fDiscount  = GetFormValue("fDiscount");
                string fRemark    = GetFormValue("fRemark");
                string fState     = GetFormValue("fState");

                int  maxPoints = fMaxPoints.ToInt();
                int  discount  = fDiscount.ToInt();
                int  showPrice = discount;
                bool state     = fState.ToBool();

                if (maxPoints <= 0)
                {
                    return(Error("升级积分必须大于0"));
                }

                if (discount <= 0 || discount > 100)
                {
                    return(Error("优惠拆扣必须是1-100之间"));
                }


                bool result = false;
                if (string.IsNullOrEmpty(rankId))
                {
                    result = RankService.SaveRankPro(SystemID, CompanyID, fRankName, maxPoints, discount, showPrice, fRemark, state);
                    var entity = RankService.GetRankByMaxPointsPro(SystemID, CompanyID, maxPoints);
                    TableOperationManager.Add(entity, result);
                }
                else
                {
                    var entity = RankService.GetRankPro(SystemID, CompanyID, rankId);
                    result = RankService.UpdateRankPro(SystemID, CompanyID, rankId, fRankName, maxPoints, discount, showPrice, fRemark, state);
                    string newEntityJson = GetNewEntityJson(entity, fRankName, maxPoints, discount, showPrice, fRemark, state);
                    TableOperationManager.Update(entity, newEntityJson, result);
                }
                if (result)
                {
                    return(Success("ok"));
                }
                else
                {
                    return(Error("fail"));
                }
            }
            catch (Exception ex)
            {
                return(Error(ex.Message));
            }
        }
        public JsonResult Save(string storeId)
        {
            try
            {
                if (!IsSavePermission(storeId))
                {
                    return(Error("您没有操作权限,请联系系统管理员!"));
                }

                string fStoreId     = GetFormValue("fStoreId");
                string fStoreName   = GetFormValue("fStoreName");
                string fContacts    = GetFormValue("fContacts");
                string fphone       = GetFormValue("fphone");
                string fTel         = GetFormValue("fTel");
                string fFax         = GetFormValue("fFax");
                string fEmail       = GetFormValue("fEmail");
                string fProvinceId  = GetFormValue("fProvinceId");
                string fCityId      = GetFormValue("fCityId");
                string fAreaId      = GetFormValue("fAreaId");
                string fAddress     = GetFormValue("fAddress");
                string fSort        = GetFormValue("fSort");
                string fDescription = GetFormValue("fDescription");
                string fState       = GetFormValue("fState");

                string   logo       = "";
                string   keyword    = fDescription.Left(100);
                DateTime startTime  = DateTime.Now;
                DateTime endTime    = DateTime.Now.AddYears(10);
                int      provinceId = fProvinceId.ToInt();
                int      cityId     = fCityId.ToInt();
                int      areaId     = fAreaId.ToInt();
                int      sort       = fSort.ToInt();
                bool     push       = false;
                bool     state      = fState.ToBool();
                if (string.IsNullOrEmpty(storeId))
                {
                    if (string.IsNullOrWhiteSpace(fStoreId))
                    {
                        return(Error("网点编号不能为空!"));
                    }
                    else
                    {
                        if (fStoreId.Length > 6)
                        {
                            return(Error("网点编号必是6位数字!"));
                        }
                    }
                    fStoreId = fStoreId.PadLeft(6, '0');
                }
                bool result = false;
                if (string.IsNullOrEmpty(storeId))
                {
                    result = StoreService.SaveStorePro(SystemID, CompanyID, fStoreId, fStoreName, logo, fContacts, fTel, fFax, fphone, fEmail, provinceId, cityId, areaId, fAddress, keyword, fDescription, startTime, endTime, push, sort, state);
                    var entity = StoreService.GetStorePro(SystemID, CompanyID, fStoreId);
                    TableOperationManager.Add(entity, result);
                }
                else
                {
                    var entity = StoreService.GetStorePro(SystemID, CompanyID, storeId);
                    result = StoreService.UpdateStorePro(SystemID, CompanyID, storeId, fStoreName, logo, fContacts, fTel, fFax, fphone, fEmail, provinceId, cityId, areaId, fAddress, keyword, fDescription, startTime, endTime, push, sort, state);
                    string newEntityJson = GetNewEntityJson(entity, fStoreName, logo, fContacts, fTel, fFax, fphone, fEmail, provinceId, cityId, areaId, fAddress, keyword, fDescription, startTime, endTime, push, sort, state);
                    TableOperationManager.Update(entity, newEntityJson, result);
                }
                if (result)
                {
                    return(Success("ok"));
                }
                else
                {
                    return(Error("fail"));
                }
            }
            catch (Exception ex)
            {
                return(Error(ex.Message));
            }
        }
        private bool SaveStaff()
        {
            try
            {
                string fStaffId      = GetFormValue("fStaffId");
                string fStaffName    = GetFormValue("fStaffName");
                string fSex          = GetFormValue("fSex");
                string fPositionId   = GetFormValue("fPositionId");
                string fDepartmentId = GetFormValue("fDepartmentId");
                string fStoreId      = GetFormValue("fStoreId");
                string fPhone        = GetFormValue("fPhone");
                string fEmail        = GetFormValue("fEmail");
                string fAddress      = GetFormValue("fAddress");
                string fDescription  = GetFormValue("fDescription");
                string fState        = GetFormValue("fState");

                if (string.IsNullOrWhiteSpace(fStaffId))
                {
                    throw new Exception("员工工号不能为空!");
                }
                if (string.IsNullOrWhiteSpace(fStaffName))
                {
                    throw new Exception("员工姓名不能为空!");
                }
                if (fPhone.Length != 11)
                {
                    throw new Exception("手机号码长度错误!");
                }
                if (!Utility.IsMobilePhone(fPhone))
                {
                    throw new Exception("手机号码格式错误!");
                }

                string password = AlgorithmHelper.MD5(Utility.Right(fPhone, 8)).ToLower();
                var    entity   = new Institution_Staff()
                {
                    SystemID     = SystemID,
                    CompanyID    = CompanyID,
                    StaffID      = fStaffId,
                    StaffName    = fStaffName,
                    UserName     = fStaffId,
                    Password     = password,
                    NickName     = fStaffName,
                    Name         = fStaffName,
                    Sex          = fSex.ToByte(),
                    Phone        = fPhone,
                    Email        = fEmail,
                    Address      = fAddress,
                    DepartmentID = fDepartmentId,
                    PositionID   = fPositionId,
                    StoreID      = fStoreId,
                    WarehouseID  = "",
                    Description  = fDescription,
                    IsInit       = false,
                    State        = fState.ToBool(),
                    IsDel        = false,
                    CreateDate   = DateTime.Now
                };
                bool result = StaffService.SaveStaffPro(entity);
                TableOperationManager.Add(entity, result);
                return(result);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }