Exemplo n.º 1
0
        /// <summary>
        /// 调价单提交到表单
        /// </summary>
        /// <param name="loggingSessionInfo"></param>
        /// <param name="adjustmentOrderInfo"></param>
        /// <returns></returns>
        private bool SetAdjustmentOrderInsertBill(LoggingSessionInfo loggingSessionInfo, AdjustmentOrderInfo adjustmentOrderInfo)
        {
            try
            {
                cPos.Model.BillModel      bill = new BillModel();
                cPos.Service.cBillService bs   = new cBillService();

                bill.Id = adjustmentOrderInfo.order_id;                                                           //order_id
                string order_type_id = bs.GetBillKindByCode(loggingSessionInfo, "ADJUSTMENTORDER").Id.ToString(); //loggingSession, OrderType
                bill.Code      = bs.GetBillNextCode(loggingSessionInfo, "CreateAdjustmentPrice");                 //BillKindCode
                bill.KindId    = order_type_id;
                bill.UnitId    = loggingSessionInfo.CurrentUserRole.UnitId;
                bill.AddUserId = loggingSessionInfo.CurrentUser.User_Id;

                BillOperateStateService state = bs.InsertBill(loggingSessionInfo, bill);

                if (state == BillOperateStateService.CreateSuccessful)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);

                throw (ex);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 修改调价单状态
        /// </summary>
        /// <param name="loggingSessionInfo">登录model</param>
        /// <param name="order_id">标识</param>
        /// <param name="billActionType">类型</param>
        /// <returns></returns>
        public bool SetAdjustmentOrderStatus(LoggingSessionInfo loggingSessionInfo, string order_id, BillActionType billActionType)
        {
            string strResult = string.Empty;

            try
            {
                cPos.Service.cBillService bs = new cBillService();

                BillOperateStateService state = bs.ApproveBill(loggingSessionInfo, order_id, "", billActionType);
                if (state == BillOperateStateService.ApproveSuccessful)
                {
                    //获取要改变的表单信息
                    BillModel billInfo = new cBillService().GetBillById(loggingSessionInfo, order_id);
                    //设置要改变的用户信息
                    AdjustmentOrderInfo itenAdjustmentOrderInfo = new AdjustmentOrderInfo();
                    itenAdjustmentOrderInfo.status         = billInfo.Status;
                    itenAdjustmentOrderInfo.status_desc    = billInfo.BillStatusDescription;
                    itenAdjustmentOrderInfo.order_id       = order_id;
                    itenAdjustmentOrderInfo.modify_user_id = loggingSessionInfo.CurrentUser.User_Id;
                    itenAdjustmentOrderInfo.modify_time    = GetCurrentDateTime(); //获取当前时间
                    //提交
                    cSqlMapper.Instance(loggingSessionInfo.CurrentLoggingManager).Update("AdjustmentOrder.UpdateStatus", itenAdjustmentOrderInfo);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 用户表单提交
        /// </summary>
        /// <param name="loggingSessionInfo">登录model</param>
        /// <param name="userInfo">用户model</param>
        /// <returns></returns>
        private bool SetUserInsertBill(LoggingSessionInfo loggingSessionInfo, UserInfo userInfo)
        {
            try
            {
                cPos.Model.BillModel      bill = new BillModel();
                cPos.Service.cBillService bs   = new cBillService();

                bill.Id = userInfo.User_Id;                                                                   //order_id
                string order_type_id = bs.GetBillKindByCode(loggingSessionInfo, "USERMANAGER").Id.ToString(); //loggingSession, OrderType
                bill.Code      = bs.GetBillNextCode(loggingSessionInfo, BillKindModel.CODE_USER_NEW);         //BillKindCode
                bill.KindId    = order_type_id;
                bill.UnitId    = loggingSessionInfo.CurrentUserRole.UnitId;
                bill.AddUserId = loggingSessionInfo.CurrentUser.User_Id;

                BillOperateStateService state = bs.InsertBill(loggingSessionInfo, bill);

                if (state == BillOperateStateService.CreateSuccessful)
                {
                    return(true);
                }
                else
                {
                    throw (new System.Exception(state.ToString()));
                }
            }
            catch (Exception ex) {
                throw (ex);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 单位停用启用
        /// </summary>
        /// <param name="unit_id">组织标识</param>
        /// <param name="iStatus">状态</param>
        /// <param name="loggingSession">登录model</param>
        /// <returns></returns>
        public bool SetUnitStatus(string unit_id, string iStatus, LoggingSessionInfo loggingSession)
        {
            try
            {
                cPos.Service.cBillService bs = new cBillService();
                UnitInfo unitInfo            = new UnitInfo();
                unitInfo.Id = unit_id;
                int            iType = 0;
                BillActionType billActionType;
                if (iStatus.Equals("1"))
                {
                    billActionType       = BillActionType.Open;
                    unitInfo.Status_Desc = "正常";
                    iType = 3;
                }
                else
                {
                    billActionType       = BillActionType.Stop;
                    unitInfo.Status_Desc = "停用";
                    iType = 4;
                }
                BillOperateStateService state = bs.ApproveBill(loggingSession, unit_id, "", billActionType);

                if (state == BillOperateStateService.ApproveSuccessful)
                {
                    if (SetUnitTableStatus(loggingSession, unit_id))
                    {
                        UnitInfo u2 = this.GetUnitById(loggingSession, unit_id);
                        if (u2 != null && u2.TypeId == "EB58F1B053694283B2B7610C9AAD2742")
                        {
#if SYN_AP
                            //单位类型是门店, 提交管理平台
                            if (!SetManagerExchangeUnitInfo(loggingSession, unitInfo, iType))
                            {
                                return(false);
                            }
#endif
                        }
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemplo n.º 5
0
        //#endregion 用户

        #region 用户的状态处理
        /// <summary>
        /// 用户停用/启用方法
        /// </summary>
        /// <param name="user_id">用户标识</param>
        /// <param name="iStatus">用户状态</param>
        /// <param name="LoggingSessionInfo">登录用户Session类</param>
        /// <returns></returns>
        public bool SetUserStatus(string user_id, string iStatus, LoggingSessionInfo LoggingSessionInfo)
        {
            cSqlMapper.Instance().BeginTransaction();
            try
            {
                cPos.Service.cBillService bs = new cBillService();
                UserInfo userInfo            = new UserInfo();
                userInfo.User_Id = user_id;

                BillActionType billActionType;
                if (iStatus.Equals("1"))
                {
                    billActionType            = BillActionType.Open;
                    userInfo.User_Status_Desc = "正常";
                }
                else
                {
                    billActionType            = BillActionType.Stop;
                    userInfo.User_Status_Desc = "停用";
                }
                BillOperateStateService state = bs.ApproveBill(LoggingSessionInfo, user_id, "", billActionType);
                if (state == BillOperateStateService.ApproveSuccessful)
                {
                    if (SetUserTableStatus(LoggingSessionInfo, user_id))
                    {
#if SYN_AP
                        // 提交管理平台
                        if (!SetManagerExchangeUserInfo(LoggingSessionInfo, userInfo, 3))
                        {
                            cSqlMapper.Instance().RollBackTransaction();
                            return(false);
                        }
#endif
                        cSqlMapper.Instance().CommitTransaction();
                        return(true);
                    }
                    else
                    {
                        cSqlMapper.Instance().RollBackTransaction();
                        return(false);
                    }
                }
                else
                {
                    cSqlMapper.Instance().RollBackTransaction();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                cSqlMapper.Instance().RollBackTransaction();
                throw (ex);
            }
        }
Exemplo n.º 6
0
 private void InitOrderNo()
 {
     try
     {
         var service = new cPos.Service.cBillService();
         this.tbOrderNo.Text = service.GetNo(loggingSessionInfo, "AJ");
     }
     catch (Exception ex)
     {
         this.InfoBox.ShowPopError("加载数据出错!");
         PageLog.Current.Write(ex.Message);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Inout状态修改(审核,删除。。。。)
        /// </summary>
        /// <param name="loggingSessionInfo"></param>
        /// <param name="order_id"></param>
        /// <param name="billActionType"></param>
        /// <param name="strError">输出信息</param>
        /// <returns></returns>
        public bool SetInoutOrderStatus(LoggingSessionInfo loggingSessionInfo, string order_id, BillActionType billActionType, out string strError)
        {
            string strResult = string.Empty;

            try
            {
                cPos.Service.cBillService bs = new cBillService();

                BillOperateStateService state = bs.ApproveBill(loggingSessionInfo, order_id, "", billActionType, out strResult);
                if (state == BillOperateStateService.ApproveSuccessful)
                {
                    //获取要改变的表单信息
                    BillModel billInfo = new cBillService().GetBillById(loggingSessionInfo, order_id);
                    //设置要改变的用户信息
                    InoutInfo inoutInfo = new InoutInfo();
                    inoutInfo.status         = billInfo.Status;
                    inoutInfo.status_desc    = billInfo.BillStatusDescription;
                    inoutInfo.order_id       = order_id;
                    inoutInfo.modify_user_id = loggingSessionInfo.CurrentUser.User_Id;
                    inoutInfo.modify_time    = GetCurrentDateTime(); //获取当前时间
                    if (billActionType == BillActionType.Approve)
                    {
                        inoutInfo.approve_time    = GetCurrentDateTime();
                        inoutInfo.approve_user_id = loggingSessionInfo.CurrentUser.User_Id;
                    }
                    //提交
                    cSqlMapper.Instance(loggingSessionInfo.CurrentLoggingManager).Update("Inout.UpdateStatus", inoutInfo);
                    strError = "审批成功";
                    return(true);
                }
                else
                {
                    strError = "获取状态失败--" + strResult;
                    return(false);
                }
            }
            catch (Exception ex)
            {
                strError = ex.ToString();
                throw (ex);
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// 设置用户表的用户状态
 /// </summary>
 /// <param name="loggingSession"></param>
 /// <param name="user_id"></param>
 /// <returns></returns>
 private bool SetUserTableStatus(LoggingSessionInfo loggingSession, string user_id)
 {
     try
     {
         //获取要改变的表单信息
         BillModel billInfo = new cBillService().GetBillById(loggingSession, user_id);
         //设置要改变的用户信息
         UserInfo userInfo = new UserInfo();
         userInfo.User_Status      = billInfo.Status;
         userInfo.User_Status_Desc = billInfo.BillStatusDescription;
         userInfo.User_Id          = user_id;
         userInfo.Modify_User_Id   = loggingSession.CurrentUser.User_Id;
         userInfo.Modify_Time      = GetCurrentDateTime(); //获取当前时间
         //提交
         cSqlMapper.Instance(loggingSession.CurrentLoggingManager).Update("User.UpdateUserStatus", userInfo);
         return(true);
     }
     catch (Exception ex) {
         throw (ex);
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// 保存调价单
        /// </summary>
        /// <param name="loggingSessionInfo"></param>
        /// <param name="adjustmentOrderInfo"></param>
        /// <returns></returns>
        public string SetAdjustmentOrderInfo(LoggingSessionInfo loggingSessionInfo, AdjustmentOrderInfo adjustmentOrderInfo)
        {
            string strResult = string.Empty;

            //事物信息
            cSqlMapper.Instance().BeginTransaction();
            try
            {
                adjustmentOrderInfo.customer_id = loggingSessionInfo.CurrentLoggingManager.Customer_Id;
                //处理是新建还是修改
                string strDo = string.Empty;
                if (adjustmentOrderInfo.order_id == null || adjustmentOrderInfo.order_id.Equals(""))
                {
                    adjustmentOrderInfo.order_id = NewGuid();
                    strDo = "Create";
                }
                else
                {
                    strDo = "Modify";
                }
                //1 判断调价单号码是否唯一
                if (!IsExistOrderCode(loggingSessionInfo, adjustmentOrderInfo.order_no, adjustmentOrderInfo.order_id))
                {
                    strResult = "订单号码已经存在。";
                    return(strResult);
                }
                //2.提交调价单信息至表单
                if (strDo.Equals("Create"))
                {
                    if (!SetAdjustmentOrderInsertBill(loggingSessionInfo, adjustmentOrderInfo))
                    {
                        strResult = "调价单表单提交失败。";
                        return(strResult);
                    }
                }

                //3.获取调价单表单信息,设置调价单状态与状态描述
                BillModel billInfo = new cBillService().GetBillById(loggingSessionInfo, adjustmentOrderInfo.order_id);
                adjustmentOrderInfo.status      = billInfo.Status;
                adjustmentOrderInfo.status_desc = billInfo.BillStatusDescription;

                //4.提交调价单信息
                if (!SetAdjustmentOrderTableInfo(loggingSessionInfo, adjustmentOrderInfo))
                {
                    strResult = "提交用户表失败";
                    return(strResult);
                }
                //5.提交调价单商品明细关系
                if (adjustmentOrderInfo.AdjustmentOrderDetailItemList != null)
                {
                    if (!new AdjustmentOrderDetailItemService().SetAdjustmentOrderDetailItemInfo(loggingSessionInfo, adjustmentOrderInfo))
                    {
                        strResult = "提交调价单商品明细失败";
                        return(strResult);
                    }
                }
                //6.提交调价单商品明细关系
                if (adjustmentOrderInfo.AdjustmentOrderDetailSkuList != null)
                {
                    if (!new AdjustmentOrderDetailSkuService().SetAdjustmentOrderDetailSkuInfo(loggingSessionInfo, adjustmentOrderInfo))
                    {
                        strResult = "提交调价单Sku明细失败";
                        return(strResult);
                    }
                }
                //7.提交调价单商品明细关系
                if (adjustmentOrderInfo.AdjustmentOrderDetailUnitList != null)
                {
                    if (!new AdjustmentOrderDetailUnitService().SetAdjustmentOrderDetailUnitInfo(loggingSessionInfo, adjustmentOrderInfo))
                    {
                        strResult = "提交调价单组织明细失败";
                        return(strResult);
                    }
                }

                cSqlMapper.Instance().CommitTransaction();
                strResult = "保存成功!";
                return(strResult);
            }catch (Exception ex) {
                cSqlMapper.Instance().RollBackTransaction();
                strResult = ex.ToString();
                throw (ex);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 保存组织信息(新建修改)
        /// </summary>
        /// <param name="loggingSessionInfo"></param>
        /// <param name="unitInfo"></param>
        /// <returns></returns>
        public string SetUnitInfo(LoggingSessionInfo loggingSessionInfo, UnitInfo unitInfo)
        {
            string strResult = string.Empty;
            int    iType;

            //事物信息
            cSqlMapper.Instance().BeginTransaction();

            try
            {
                unitInfo.customer_id = loggingSessionInfo.CurrentLoggingManager.Customer_Id;
                //处理是新建还是修改
                if (unitInfo.Id == null || unitInfo.Id.Equals(""))
                {
                    unitInfo.Id = NewGuid();
                    iType       = 1;
                }
                else
                {
                    iType = 2;
                }

                //1 判断组织号码是否唯一
                if (!IsExistUnitCode(loggingSessionInfo, unitInfo.Code, unitInfo.Id))
                {
                    strResult = "组织号码已经存在。";
                    return(strResult);
                }

                //2.提交用户信息至表单
                if (iType.ToString().Equals("1"))
                {
                    if (!SetUnitInsertBill(loggingSessionInfo, unitInfo))
                    {
                        strResult = "组织表单提交失败。";
                        return(strResult);
                    }
                }

                //3.获取用户表单信息,设置用户状态与状态描述
                BillModel billInfo = new cBillService().GetBillById(loggingSessionInfo, unitInfo.Id);
                unitInfo.Status      = billInfo.Status;
                unitInfo.Status_Desc = billInfo.BillStatusDescription;

                //4.提交用户信息
                if (!SetUnitTableInfo(loggingSessionInfo, unitInfo))
                {
                    strResult = "提交用户表失败";
                    return(strResult);
                }
//#if SYN_AP
                // 单位类型是门店,提交管理平台
                if (unitInfo.TypeId.Equals("EB58F1B053694283B2B7610C9AAD2742"))
                {
                    if (!SetManagerExchangeUnitInfo(loggingSessionInfo, unitInfo, iType))
                    {
                        return("提交管理平台失败");
                    }
                }
//#endif
                ////刷新单位级别数据
                //cSqlMapper.Instance().QueryForObject("Unit.RefreshUnitLevel", null);
                cSqlMapper.Instance().CommitTransaction();
                strResult = "保存成功!";

                return(strResult);
            }
            catch (Exception ex) {
                cSqlMapper.Instance().RollBackTransaction();
                throw (ex);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 用户保存
        /// </summary>
        /// <param name="loggingSessionInfo">登录用户信息</param>
        /// <param name="userInfo">处理的用户类</param>
        /// <param name="userRoleInfos">用户角色组织关系类集合</param>
        /// <param name="strError">错误信息</param>
        /// <returns></returns>
        public bool SetUserInfo(LoggingSessionInfo loggingSessionInfo, UserInfo userInfo, IList <UserRoleInfo> userRoleInfos, out string strError)
        {
            string strResult = string.Empty;
            bool   bReturn   = true;

            //事物信息
            cSqlMapper.Instance().BeginTransaction();
            try
            {
                userInfo.customer_id = loggingSessionInfo.CurrentLoggingManager.Customer_Id;
                //处理是新建还是修改
                string strDo = string.Empty;
                if (userInfo.User_Id == null || userInfo.User_Id.Equals(""))
                {
                    userInfo.User_Id       = NewGuid();
                    strDo                  = "Create";
                    userInfo.User_Password = EncryptManager.Hash(userInfo.User_Password, HashProviderType.MD5);
                }
                else
                {
                    strDo = "Modify";
                }
                //1 判断用户号码是否唯一
                if (!IsExistUserCode(loggingSessionInfo, userInfo.User_Code, userInfo.User_Id))
                {
                    strError = "用户号码已经存在。";
                    bReturn  = false;
                    return(bReturn);
                }
                //2.提交用户信息至表单
                if (strDo.Equals("Create"))
                {
                    if (!SetUserInsertBill(loggingSessionInfo, userInfo))
                    {
                        strError = "用户表单提交失败。";
                        bReturn  = false;
                        return(bReturn);
                    }
                }

                //3.获取用户表单信息,设置用户状态与状态描述
                BillModel billInfo = new cBillService().GetBillById(loggingSessionInfo, userInfo.User_Id);
                userInfo.User_Status      = billInfo.Status;
                userInfo.User_Status_Desc = billInfo.BillStatusDescription;

                //4.提交用户信息
                if (!SetUserTableInfo(loggingSessionInfo, userInfo))
                {
                    strError = "提交用户表失败";
                    bReturn  = false;
                    return(bReturn);
                }
                //5.提交用户与角色与组织关系
                if (!SetUserRoleTableInfo(loggingSessionInfo, userRoleInfos, userInfo))
                {
                    strError = "提交用户与角色,组织表失败";
                    bReturn  = false;
                    return(bReturn);
                }
#if SYN_AP
                // 提交管理平台
                if (!SetManagerExchangeUserInfo(loggingSessionInfo, userInfo, strDo == "Create" ? 1 : 2))
                {
                    strError = "提交管理平台失败";
                    bReturn  = false;
                    return(bReturn);
                }
#endif

#if SYN_DEX
                // 提交接口
                if (strDo.Equals("Create"))
                {
                    strResult = SetDexUserCertificate(loggingSessionInfo, userInfo);
                    if (!(strResult.Equals("True") || strResult.Equals("true")))
                    {
                        cSqlMapper.Instance().RollBackTransaction();
                        strError = "提交接口失败";
                        bReturn  = false;
                        return(bReturn);
                    }
                }
                else
                {
                    bool bResult = SetDexUpdateUserCertificate(loggingSessionInfo, userInfo, out strError);
                    if (!bResult)
                    {
                        cSqlMapper.Instance().RollBackTransaction();
                        return(false);
                    }
                }
#endif

                cSqlMapper.Instance().CommitTransaction();
                strError = "保存成功!";
                return(bReturn);
            }
            catch (Exception ex) {
                cSqlMapper.Instance().RollBackTransaction();
                strError = ex.ToString();
                throw (ex);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// 设置业务平台客户开户初始化
        /// </summary>
        /// <param name="strCustomerInfo">客户信息字符窜</param>
        /// <param name="strUnitInfo">门店信息字符窜</param>
        /// <param name="typeId">处理类型typeId=1(总部与门店一起处理);typeId=2(只处理总部,不处理门店);typeId=3(只处理门店,不处理总部)</param>
        /// <returns></returns>
        public bool SetBSInitialInfo(string strCustomerInfo, string strUnitInfo, string strMenu, string typeId)
        {
            CustomerInfo customerInfo = new CustomerInfo();

            #region 获取客户信息
            if (!strCustomerInfo.Equals(""))
            {
                customerInfo = (cPos.Model.CustomerInfo)cXMLService.Deserialize(strCustomerInfo, typeof(cPos.Model.CustomerInfo));
                if (customerInfo == null || customerInfo.ID.Equals(""))
                {
                    throw new Exception("客户不存在或者没有获取合法客户信息");
                }
            }
            else
            {
                throw new Exception("客户信息不存在.");
            }
            #endregion
            //获取连接数据库信息

            LoggingManager loggingManager = new cLoggingManager().GetLoggingManager(customerInfo.ID);

            #region 判断客户是否已经建立总部
            UnitInfo unitHeadInfo = new UnitService().GetUnitTopByCustomerId(loggingManager, customerInfo.ID);
            if (unitHeadInfo == null || unitHeadInfo.Id.Equals(""))
            {
                typeId = "1";
            }
            else
            {
                typeId = "3";
            }
            #endregion

            UnitInfo unitShopInfo = new UnitInfo();//门店
            if (!strUnitInfo.Equals(""))
            {
                unitShopInfo = (cPos.Model.UnitInfo)cXMLService.Deserialize(strUnitInfo, typeof(cPos.Model.UnitInfo));
            }
            else
            {
                throw new Exception("门店信息不存在.");
            }

            #region 门店是否存在
            UnitInfo unitStoreInfo2 = new UnitInfo();
            try
            {
                unitStoreInfo2 = new UnitService().GetUnitById(loggingManager, unitShopInfo.Id);
            }
            catch (Exception ex)
            {
                throw new Exception("用户插入管理平台失败:" + ex.ToString());
            }
            if (unitStoreInfo2 != null && string.IsNullOrEmpty(unitStoreInfo2.Id))
            {
                throw new Exception("门店信息已经存在.");
            }
            #endregion

            cSqlMapper.Instance(loggingManager).BeginTransaction();
            //try
            //{
            bool bReturn = false;
            #region 处理用户信息
            cPos.Model.User.UserInfo userInfo = new Model.User.UserInfo();
            if (typeId.Equals("1"))
            {
                userInfo.User_Id          = NewGuid();       //用户标识
                userInfo.customer_id      = customerInfo.ID; //客户标识
                userInfo.User_Code        = "admin";
                userInfo.User_Name        = "管理员";
                userInfo.User_Gender      = "1";
                userInfo.User_Password    = "******";
                userInfo.User_Status      = "1";
                userInfo.User_Status_Desc = "正常";
                bReturn = new cUserService().SetUserTableInfo(loggingManager, userInfo);
                if (!bReturn)
                {
                    throw new Exception("保存用户失败");
                }
            }
            else
            {
                userInfo = new cUserService().GetUserDefaultByCustomerId(loggingManager, customerInfo.ID);
            }
            #endregion

            #region 处理新建客户总部
            cPos.Model.UnitInfo unitInfo = new Model.UnitInfo();
            if (typeId.Equals("1") || typeId.Equals("2"))
            {
                unitInfo.Id             = NewGuid();
                unitInfo.TypeId         = "2F35F85CF7FF4DF087188A7FB05DED1D";
                unitInfo.Code           = customerInfo.Code + "总部";
                unitInfo.Name           = customerInfo.Name + "总部";
                unitInfo.CityId         = customerInfo.city_id;
                unitInfo.Status         = "1";
                unitInfo.Status_Desc    = "正常";
                unitInfo.CustomerLevel  = 1;
                unitInfo.customer_id    = customerInfo.ID;
                unitInfo.Parent_Unit_Id = "-99";
                bReturn = new UnitService().SetUnitTableInfo(loggingManager, unitInfo, userInfo);
                if (!bReturn)
                {
                    throw new Exception("新建客户总部失败");
                }
            }
            else
            {
                unitInfo = new UnitService().GetUnitTopByCustomerId(loggingManager, customerInfo.ID);
            }
            #endregion

            #region 处理门店
            cPos.Model.UnitInfo storeInfo = new UnitInfo();
            storeInfo.Id             = unitShopInfo.Id;
            storeInfo.TypeId         = "EB58F1B053694283B2B7610C9AAD2742";
            storeInfo.Code           = customerInfo.Code;
            storeInfo.Name           = customerInfo.Name;
            storeInfo.CityId         = customerInfo.city_id;
            storeInfo.Status         = "1";
            storeInfo.Status_Desc    = "正常";
            storeInfo.CustomerLevel  = 1;
            storeInfo.customer_id    = customerInfo.ID;
            storeInfo.Parent_Unit_Id = unitInfo.Id;
            bReturn = new UnitService().SetUnitTableInfo(loggingManager, storeInfo, userInfo);
            if (!bReturn)
            {
                throw new Exception("新建门店失败");
            }
            #endregion

            #region 新建角色

            cPos.Model.RoleModel roleInfo = new RoleModel();
            if (typeId.Equals("1"))
            {
                roleInfo.Role_Id        = NewGuid();
                roleInfo.Def_App_Id     = "D8C5FF6041AA4EA19D83F924DBF56F93";
                roleInfo.Role_Code      = "Admin";
                roleInfo.Role_Name      = "管理员";
                roleInfo.Role_Eng_Name  = "administrator";
                roleInfo.Is_Sys         = 1;
                roleInfo.Status         = 1;
                roleInfo.customer_id    = customerInfo.ID;
                roleInfo.Create_User_Id = userInfo.User_Id;
                roleInfo.Create_Time    = GetCurrentDateTime();
                bReturn = new RoleService().SetRoleInfo(loggingManager, roleInfo);
                if (!bReturn)
                {
                    throw new Exception("新建角色失败");
                }
            }
            else
            {
                roleInfo = new RoleService().GetRoleDefaultByCustomerId(loggingManager, customerInfo.ID);
            }
            #endregion

            #region 插入用户与角色与客户总部关系
            IList <cPos.Model.User.UserRoleInfo> userRoleInfoList = new List <cPos.Model.User.UserRoleInfo>();
            if (typeId.Equals("1") || typeId.Equals("2"))
            {
                cPos.Model.User.UserRoleInfo userRoleInfo = new Model.User.UserRoleInfo();
                userRoleInfo.Id          = NewGuid();
                userRoleInfo.UserId      = userInfo.User_Id;
                userRoleInfo.RoleId      = roleInfo.Role_Id;
                userRoleInfo.UnitId      = unitInfo.Id;
                userRoleInfo.Status      = "1";
                userRoleInfo.DefaultFlag = 1;
                userRoleInfoList.Add(userRoleInfo);
            }
            cPos.Model.User.UserRoleInfo userRoleInfo1 = new Model.User.UserRoleInfo();
            userRoleInfo1.Id          = NewGuid();
            userRoleInfo1.UserId      = userInfo.User_Id;
            userRoleInfo1.RoleId      = roleInfo.Role_Id;
            userRoleInfo1.UnitId      = storeInfo.Id;
            userRoleInfo1.Status      = "1";
            userRoleInfo1.DefaultFlag = 1;
            userRoleInfoList.Add(userRoleInfo1);
            bReturn = new cUserService().SetUserRoleTableInfo(loggingManager, userRoleInfoList, userInfo);
            if (!bReturn)
            {
                throw new Exception("新建角色用户门店关系失败");
            }
            #endregion

            #region 添加仓库以及仓库与门店关系
            cPos.Model.Pos.WarehouseInfo warehouseInfo = new cPos.Model.Pos.WarehouseInfo();
            warehouseInfo.ID             = NewGuid();
            warehouseInfo.Code           = storeInfo.Code + "_wh";
            warehouseInfo.Name           = storeInfo.Name + "仓库";
            warehouseInfo.IsDefault      = 1;
            warehouseInfo.Status         = 1;
            warehouseInfo.CreateUserID   = userInfo.User_Id;
            warehouseInfo.CreateTime     = Convert.ToDateTime(GetCurrentDateTime());
            warehouseInfo.CreateUserName = userInfo.User_Name;
            warehouseInfo.Unit           = storeInfo;

            cPos.Service.PosService posService = new PosService();
            bReturn = posService.InsertWarehouse(loggingManager, warehouseInfo, false);
            if (!bReturn)
            {
                throw new Exception("新建仓库失败");
            }
            #endregion


            #region 设置菜单信息
            if (typeId.Equals("1") || typeId.Equals("2"))
            {
                if (!strMenu.Equals(""))
                {
                    bReturn = new cMenuService().SetMenuInfo(strMenu, customerInfo.ID, false);
                    if (!bReturn)
                    {
                        throw new Exception("新建菜单失败");
                    }
                }
            }
            #endregion

            #region 角色与流程关系
            if (typeId.Equals("1"))
            {
                Hashtable _ht = new Hashtable();
                _ht.Add("RoleId", roleInfo.Role_Id);
                bReturn = new cBillService().SetBatBillActionRole(_ht, loggingManager);
                if (!bReturn)
                {
                    throw new Exception("创建角色与流程关系失败");
                }
            }
            #endregion

            #region 管理平台--插入客户下的用户信息
            //if (typeId.Equals("1"))
            //{
            //    try
            //    {
            //        bReturn = new cUserService().SetManagerExchangeUserInfo(loggingManager, userInfo, 1);
            //        if (!bReturn) { throw new Exception("用户插入管理平台失败"); }
            //    }
            //    catch (Exception ex) {
            //        cSqlMapper.Instance(loggingManager).RollBackTransaction();
            //        throw new Exception("用户插入管理平台失败:" + ex.ToString());
            //    }
            //}
            #endregion

            #region 管理平台--插入客户下的门店信息

            //bReturn = new UnitService().SetManagerExchangeUnitInfo(loggingManager, storeInfo, 1);
            //if (!bReturn) { throw new Exception("门店插入管理平台失败"); }
            #endregion

            #region 中间层--插入用户,客户关系
            //if (typeId.Equals("1"))
            //{
            //    try
            //    {
            //        string strError = string.Empty;
            //        userInfo.customer_id = customerInfo.ID;
            //        bReturn = new cUserService().SetDexUserCertificate(customerInfo.Code, userInfo, out strError);
            //        if (!bReturn) { throw new Exception(strError); }
            //    }
            //    catch (Exception ex)
            //    {
            //        cSqlMapper.Instance(loggingManager).RollBackTransaction();
            //        throw new Exception("插入中间层失败:" + ex.ToString());
            //    }
            //}
            #endregion

            cSqlMapper.Instance(loggingManager).CommitTransaction();
            return(bReturn);
        }
Exemplo n.º 13
0
        /// <summary>
        /// inout 单据保存
        /// </summary>
        /// <param name="loggingSessionInfo">登录model</param>
        /// <param name="inoutInfo">inout model</param>
        /// <param name="IsTrans">是否批处理</param>
        /// <param name="strError">输出错误信息</param>
        /// <returns></returns>
        public bool SetInoutInfo(LoggingSessionInfo loggingSessionInfo, InoutInfo inoutInfo, bool IsTrans, out string strError)
        {
            string strDo = string.Empty;

            if (IsTrans)
            {
                cSqlMapper.Instance(loggingSessionInfo.CurrentLoggingManager).BeginTransaction();
            }
            try
            {
                if (inoutInfo.order_id == null || inoutInfo.order_id.Equals(""))
                {
                    inoutInfo.order_id = NewGuid();
                    inoutInfo.operate  = "Create";
                }
                if (inoutInfo.Equals("Create"))
                {
                    //1.判断重复
                    if (!IsExistOrderCode(loggingSessionInfo, inoutInfo.order_no, inoutInfo.order_id))
                    {
                        strError = "订单号码已经存在。";
                        //return false;
                        throw (new System.Exception(strError));
                    }
                }
                //判断是否有上级订单信息
                if (inoutInfo.ref_order_no != null && (!inoutInfo.ref_order_no.Equals("")) && (inoutInfo.ref_order_id == null || inoutInfo.ref_order_id.Equals("")))
                {
                    string orderId = GetOrderIdByOrderCode(loggingSessionInfo, inoutInfo.ref_order_no);
                    if (orderId != null && (!orderId.Equals("")))
                    {
                        inoutInfo.ref_order_id = orderId;
                    }
                }
                string strCount = string.Empty;
                if (inoutInfo.operate.Equals("Create") &&
                    (!new cBillService().CanHaveBill(loggingSessionInfo, inoutInfo.order_id, out strCount))
                    )
                {
                    //2.提交表单
                    if (!SetInoutOrderInsertBill(loggingSessionInfo, inoutInfo))
                    {
                        strError = "inout表单提交失败。";
                        throw (new System.Exception(strError));
                    }
                    //3.更改状态
                    BillModel billInfo = new cBillService().GetBillById(loggingSessionInfo, inoutInfo.order_id);
                    if (billInfo != null)
                    {
                        inoutInfo.status      = billInfo.Status;
                        inoutInfo.status_desc = billInfo.BillStatusDescription;
                        strDo = billInfo.Status + "--" + inoutInfo.order_id;
                    }
                    else
                    {
                        strDo = "没找到对应的bill";
                    }
                }
                else
                {
                    strDo = "存在相同的表单:" + strCount + ":-- " + loggingSessionInfo.CurrentLoggingManager.Connection_String + "--";
                }

                //4.提交inout与inoutdetail信息
                if (!SetInoutTableInfo(loggingSessionInfo, inoutInfo))
                {
                    strError = "提交用户表失败";
                    throw (new System.Exception(strError));
                }
                if (IsTrans)
                {
                    cSqlMapper.Instance().CommitTransaction();
                }
                strError = "保存成功!";
                return(true);
            }
            catch (Exception ex)
            {
                if (IsTrans)
                {
                    cSqlMapper.Instance().RollBackTransaction();
                }
                throw (ex);
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// 单个POS小票保存处理
 /// </summary>
 /// <param name="loggingSessionInfo">登录Model</param>
 /// <param name="inoutInfo">inoutmodel</param>
 /// <param name="IsTrans">是否批处理</param>
 /// <param name="strError">输出错误信息</param>
 /// <returns>返回真假</returns>
 public bool SetPosInoutInfo(LoggingSessionInfo loggingSessionInfo, InoutInfo inoutInfo, bool IsTrans, out string strError)
 {
     try
     {
         if (inoutInfo.order_id == null || inoutInfo.order_id.Equals(""))
         {
             inoutInfo.order_id = NewGuid();
         }
         if (inoutInfo.BillKindCode == null || inoutInfo.BillKindCode.Equals(""))
         {
             inoutInfo.BillKindCode = "DO";
         }
         string strResult             = string.Empty;
         cPos.Service.cBillService bs = new cBillService();
         if (bs.CanHaveBill(loggingSessionInfo, inoutInfo.order_id, out strResult))
         {
             //Jermyn20130717 单据重复也可以上传
             //throw (new System.Exception(inoutInfo.order_no + "单据重复"));
             inoutInfo.operate = "Modify";
         }
         if (inoutInfo.operate == null || inoutInfo.operate.Equals(""))
         {
             inoutInfo.operate = "Create";
         }
         //提交信息
         bool   bResult = new InoutService().SetInoutInfo(loggingSessionInfo, inoutInfo, IsTrans, out strResult);
         string aa      = strResult;
         #region
         if (bResult && inoutInfo.operate.Equals("Create"))
         {
             //审批
             if (new InoutService().SetInoutOrderStatus(loggingSessionInfo, inoutInfo.order_id, BillActionType.Approve, out strResult))
             {
                 //扣库存
                 if (new StockBalanceService().SetStockBalance(loggingSessionInfo, inoutInfo.order_id))
                 {
                     strError = "成功!";
                     return(true);
                 }
                 else
                 {
                     strError = "扣库存失败";
                     return(false);
                 }
             }
             else
             {
                 strError = "审批失败--" + aa + "--" + strResult;
                 throw (new System.Exception(strError));
             }
         }
         else
         {
             strError = strResult;
             //throw (new System.Exception(strError));
             return(bResult);
         }
         #endregion
     }
     catch (Exception ex) {
         throw (ex);
     }
 }
Exemplo n.º 15
0
        /// <summary>
        /// 处理盘点单信息(新建,修改)
        /// </summary>
        /// <param name="loggingSessionInfo">登录model</param>
        /// <param name="ccInfo">盘点单model</param>
        /// <param name="IsTrans">是否批处理</param>
        /// <param name="strError">返回错误信息</param>
        /// <returns></returns>
        public bool SetCCInfo(LoggingSessionInfo loggingSessionInfo, CCInfo ccInfo, bool IsTrans, out string strError)
        {
            string strDo = string.Empty;

            if (IsTrans)
            {
                cSqlMapper.Instance().BeginTransaction();
            }
            try
            {
                ccInfo.customer_id = loggingSessionInfo.CurrentLoggingManager.Customer_Id;
                if (ccInfo.if_flag == null || ccInfo.if_flag.ToString().Trim().Equals(""))
                {
                    ccInfo.if_flag = "0";
                }
                if (ccInfo.order_type_id == null || ccInfo.order_type_id.Equals(""))
                {
                    ccInfo.order_type_id = "51BE351BFA5E49A490103669EA21BC3C";
                }
                if (ccInfo.BillKindCode == null || ccInfo.BillKindCode.Equals(""))
                {
                    ccInfo.BillKindCode = "CC";
                }
                if (ccInfo.order_id == null || ccInfo.order_id.Equals(""))
                {
                    ccInfo.order_id = NewGuid();
                }
                //1.判断重复
                if (!IsExistOrderCode(loggingSessionInfo, ccInfo.order_no, ccInfo.order_id))
                {
                    strError = "订单号码已经存在。";
                    throw (new System.Exception(strError));
                }
                if (ccInfo.operate == null || ccInfo.operate.Equals(""))
                {
                    ccInfo.operate = "Create";
                }
                if (ccInfo.operate.Equals("Create"))
                {
                    //2.提交表单
                    if (!SetInoutOrderInsertBill(loggingSessionInfo, ccInfo))
                    {
                        strError = "盘点单表单提交失败。";
                        throw (new System.Exception(strError));
                    }
                    //3.更改状态
                    BillModel billInfo = new cBillService().GetBillById(loggingSessionInfo, ccInfo.order_id);
                    if (billInfo != null)
                    {
                        ccInfo.status      = billInfo.Status;
                        ccInfo.status_desc = billInfo.BillStatusDescription;
                    }
                }

                //4.提交cc与ccdetail信息
                if (!SetCCTableInfo(loggingSessionInfo, ccInfo))
                {
                    strError = "提交用户表失败";
                    throw (new System.Exception(strError));
                }
                if (IsTrans)
                {
                    cSqlMapper.Instance().CommitTransaction();
                }
                strError = "保存成功!";
                return(true);
            }
            catch (Exception ex)
            {
                if (IsTrans)
                {
                    cSqlMapper.Instance().RollBackTransaction();
                }
                throw (ex);
            }
        }