예제 #1
0
        public HomeForm(CheckoutModel checkoutModel, ResultJSON resultJSONTemp)
        {
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            this.model      = checkoutModel;
            this.resultJSON = resultJSONTemp;
            InitializeComponent();

            Timer = new System.Windows.Forms.Timer()
            {
                Interval = 100
            };
            Timer.Tick  += new EventHandler(Timer_Tick);
            base.Opacity = 0;
            Timer.Start();
        }
예제 #2
0
        /// <summary>
        /// 结算订单
        /// </summary>
        /// <param name="model">Model</param>
        /// <returns></returns>
        public ResultJSON <Order> Pay(Order model)
        {
            ResultJSON <Order> ret = new ResultJSON <Order> {
                Code = 0
            };
            Order o = _dbContext.Orders.Find(model.Id);

            o.PayState = model.PayState;
            o.Cashier  = CurrentUser;

            //计算订单销售提成,未结算、挂账、已结算都计算提成
            o.SalesCommission = (o.Price - o.MinPrice) * o.Count * 0.2M;

            //新增付款记录Payment
            foreach (Payment p in model.Payments)
            {
                //要加载order下才会关联OrderId,直接加在db下不会反应关联关系
                o.Payments.Add(p);
                if (p.PayTypeId == OrderPayType.账户扣减 || p.PayTypeId == OrderPayType.公司账户扣减)
                {
                    bool isCompany = (p.PayTypeId == OrderPayType.公司账户扣减) ? true : false;
                    if (!model.ClientId.HasValue)
                    {
                        ret.Code = 500;
                        ret.Msg  = "请检查是否存在该客户";
                        break;
                    }
                    //新增消费记录并且扣减账户余额
                    cl_r.CurrentUser = CurrentUser;
                    ChargeLog cl = new ChargeLog
                    {
                        PayType    = (isCompany) ? OrderPayType.公司账户扣减 : OrderPayType.账户扣减,
                        ChargeType = ChargeType.消费,
                        Money      = p.Money,
                        IsCompany  = isCompany
                    };
                    if (model.ClientId.HasValue)
                    {
                        cl.ClientId = int.Parse(model.ClientId.ToString());
                    }

                    ChargeLog cl_return = cl_r.InsertAndUpdateBalances(cl);

                    if (cl_return == null)
                    {
                        ret.Code = 500;
                        ret.Msg  = "扣减金额必须少于或等于账户余额";
                        break;
                    }
                }
            }

            if (ret.Code == 500)
            {
                return(ret);
            }

            //更新计划状态为“已完成”
            if (o.SalesPlanId != null)
            {
                var sp = _dbContext.SalesPlans.Where(s => s.Id == o.SalesPlanId).FirstOrDefault();
                sp.State = SalesPlanState.已完成;
            }

            o.LastUpdatedAt = DateTime.Now;

            Save();
            ret.Data = o;

            return(ret);
        }
예제 #3
0
        /// <summary>
        /// 获取注册码
        /// </summary>
        public void GetRegisterCode()
        {
            try
            {
                loadingfrm = new SimpleLoading(this);
                //将Loaing窗口,注入到 SplashScreenManager 来管理
                loading = new SplashScreenManager(loadingfrm);
                loading.ShowLoading();

                if (this.model.res == 0)
                {
                    try
                    {
                        string        url      = EnConfigHelper.GetConfigValue("request", "url");
                        string        apistr   = url + "/app/allInOneClient/getClientStatus";
                        StringBuilder postData = new StringBuilder();
                        postData.Append("{");
                        postData.Append("licence_code:\"" + this.model.sericalNumber + "\",");
                        postData.Append("mac_code:\"" + this.model.registerCode + "\"");
                        postData.Append("}");
                        //接口调用
                        string strJSON = HttpHelper.PostUrl(apistr, postData.ToString());
                        //返回结果
                        json = HttpHelper.Deserialize <ResultJSON>(strJSON);
                        if (json.result == "true")
                        {
                            loading.CloseWaitForm();
                            this.json.data.checkItemList.Insert(0, new CheckModel {
                                tempPropID = 0, propName = "全部"
                            });
                            this.DialogResult = DialogResult.OK;//关键:设置登陆成功状态
                            this.Close();
                        }
                        else
                        {
                            loading.CloseWaitForm();
                            MessageBox.Show("激活码已存在:" + json.message.ToString());
                            /*可选处理异常*/
                            LogHelper.WriteLine("RegisterFrm:" + json.message.ToString());
                            this.Close();
                            this.Dispose();
                        }
                    }
                    catch (Exception ex)
                    {
                        loading.CloseWaitForm();
                        MessageBox.Show("服务器出错:" + ex.Message.ToString());
                        /*可选处理异常*/
                        LogHelper.WriteLine("RegisterFrm:" + ex.Message.ToString());
                        this.Close();
                        this.Dispose();
                    }
                }
                else if (this.model.res == 1)//软件尚未注册
                {
                    try
                    {
                        if (this.txt_cdkey.Text.ToString().Trim().Length > 0)
                        {
                            this.model.sericalNumber = this.txt_cdkey.Text.ToString().Trim();
                            //date
                            string dateNow = RegeditTime.GetNowDate();
                            //生成序列号
                            this.model.registerCode = RegeditTime.CreatSerialNumber(this.model.sericalNumber, dateNow);

                            string url    = EnConfigHelper.GetConfigValue("request", "url");
                            string apistr = url + "/app/allInOneClient/startRegister";
                            //向java端进行注册请求

                            StringBuilder postData = new StringBuilder();
                            postData.Append("{");
                            postData.Append("licence_code:\"" + this.model.sericalNumber + "\",");
                            postData.Append("mac_code:\"" + this.model.registerCode + "\"");
                            postData.Append("}");
                            //接口调用

                            string strJSON = HttpHelper.PostUrl(apistr, postData.ToString());
                            //返回结果
                            json = HttpHelper.Deserialize <ResultJSON>(strJSON);
                            if (json.result == "true")
                            {
                                string        url1      = EnConfigHelper.GetConfigValue("request", "url");
                                string        apistr1   = url1 + "/app/allInOneClient/getClientStatus";
                                StringBuilder postData1 = new StringBuilder();
                                postData1.Append("{");
                                postData1.Append("licence_code:\"" + this.model.sericalNumber + "\",");
                                postData1.Append("mac_code:\"" + this.model.registerCode + "\"");
                                postData1.Append("}");
                                //接口调用
                                string strJSON1 = HttpHelper.PostUrl(apistr1, postData1.ToString());
                                //返回结果
                                json = HttpHelper.Deserialize <ResultJSON>(strJSON1);
                                if (json.result == "true")
                                {
                                    //写入到注册表
                                    RegeditTime.WriteSetting(this.model.path, this.model.registerCodeName, this.model.registerCode);

                                    this.model.res = 0;
                                    loading.CloseWaitForm();

                                    this.json.data.checkItemList.Insert(0, new CheckModel {
                                        tempPropID = 0, propName = "全部"
                                    });

                                    DialogResult dr = MessageBox.Show("注册成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    if (dr == DialogResult.OK)
                                    {
                                        loading.CloseWaitForm();
                                        this.DialogResult = DialogResult.OK;//关键:设置登陆成功状态
                                        this.Close();
                                    }
                                }
                                else
                                {
                                    loading.CloseWaitForm();
                                    lbl_note.Text = "错误:" + json.message.ToString() + "";
                                }
                            }
                            else
                            {
                                loading.CloseWaitForm();
                                lbl_note.Text = "注册失败:" + json.message.ToString() + "";
                            }
                        }
                        else
                        {
                            loading.CloseWaitForm();
                            lbl_note.Text = "请输入激活码";
                        }
                    }
                    catch (Exception ex)
                    {
                        loading.CloseWaitForm();
                        MessageBox.Show("服务器出错:" + ex.Message.ToString());
                        /*可选处理异常*/
                        LogHelper.WriteLine("RegisterFrm:" + ex.Message.ToString());
                        this.Close();
                        this.Dispose();
                    }
                }
                else if (this.model.res == 2)//注册机器与本机不一致
                {
                    loading.CloseWaitForm();
                    MessageBox.Show("注册机器与本机不一致!");
                    this.Close();
                    this.Dispose();
                }
                else if (this.model.res == 3)//软件试用已到期
                {
                    loading.CloseWaitForm();
                    MessageBox.Show("软件试用已到期!");
                    this.Close();
                    this.Dispose();
                }
                else if (this.model.res == 4)//激活码与注册码不匹配
                {
                    loading.CloseWaitForm();
                    MessageBox.Show("激活码与注册码不匹配!");
                    this.Close();
                    this.Dispose();
                }
                else//软件运行已到期
                {
                    loading.CloseWaitForm();
                    MessageBox.Show("软件运行已到期!");
                    this.Close();
                    this.Dispose();
                }
            }
            catch (Exception e)
            {
                loading.CloseWaitForm();
                MessageBox.Show("服务器出错:" + e.Message.ToString());
                this.Close();
                this.Dispose();
            }
        }