Пример #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            var container    = this.tabControl1.TabPages[tabControl1.SelectedIndex];
            var controls_txt = container.Controls.Find("TXT", false);

            #region 检测输入

            if (this.cbox.SelectedIndex == 0)
            {
                MessageEx.ShowWarning("请选择客户");
                return;
            }

            if (string.IsNullOrWhiteSpace(txtIssue.Text))
            {
                MessageEx.ShowWarning("请输入期号");
                return;
            }
            if (txtIssue.Text.Trim().Length != 7)
            {
                MessageEx.ShowWarning("请输入正确的期号");
                return;
            }
            var flag = false;
            foreach (var control in controls_txt)
            {
                if (control is TextBox)
                {
                    var c = control as TextBox;
                    if (!string.IsNullOrWhiteSpace(c.Text))
                    {
                        flag = true;
                    }
                }
            }
            if (flag == false)
            {
                MessageEx.ShowWarning("请输入内容,内容不能为空");
                return;
            }


            #endregion


            var OrderId = Guid.NewGuid().ToString("n");
            var list    = new List <OrderTM>();
            var index   = 1;
            foreach (var control in controls_txt)
            {
                if (control is TextBox)
                {
                    var c = control as TextBox;
                    if (!string.IsNullOrWhiteSpace(c.Text))
                    {
                        OrderTM O = new OrderTM();
                        O.Id        = Guid.NewGuid().ToString("N");
                        O.OrderId   = OrderId;
                        O.InMoney   = Convert.ToDecimal(c.Text);
                        O.Status    = (int)ResultStatus.Wait;
                        O.Flag      = 1;
                        O.ChildType = (int)ChildType.平特;

                        O.Sort = index;

                        var Code = container.Controls.Find("Code", false).FirstOrDefault(x => x.Tag == c.Tag);
                        if (Code != null)
                        {
                            var lbCode = Code as Label;
                            O.Code    = lbCode.Text;
                            O.Remarks = lbCode.Text;
                        }
                        else
                        {
                            continue;
                        }

                        var PL = container.Controls.Find("PL", false).FirstOrDefault(x => x.Tag == c.Tag);
                        if (PL != null)
                        {
                            var lbPL = PL as Label;
                            O.Odds = Convert.ToDecimal(lbPL.Text);
                        }
                        else
                        {
                            continue;
                        }
                        O.OutMoney = O.Odds * O.InMoney;
                        list.Add(O);
                        index = index + 1;
                    }
                }
            }
            var order = new Order <OrderTM>()
            {
                Create_Time     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                Create_User_Id  = "0",
                Customer_Id     = cbox.SelectedValue.ToString().ToTryInt(),
                Id              = OrderId,
                IsDel           = 0,
                Issue           = txtIssue.Text.Trim(),
                Order_No        = ServiceNum.GetOrderNo(),
                Order_Type      = (int)OrderType.平特,
                Child_Type      = (int)ChildType.平特,
                Total_In_Money  = list.Sum(x => x.InMoney),
                Total_Out_Money = 0,
                Update_Time     = "",
                Update_User_Id  = "",
                OrderDetails    = list
            };
            fmConfirmOther fm = new fmConfirmOther();
            fm.InitForm(order);
            if (fm.ShowDialog() == DialogResult.OK)
            {
                OrderImpl services = new OrderImpl();
                if (services.AddOrderTM(order).Code == 0)
                {
                    MessageEx.Show("成功");
                    btnReset_Click(sender, e);
                }
                else
                {
                    MessageEx.ShowWarning("失败");
                }
            }
        }
Пример #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string OrderId = Guid.NewGuid().ToString("n");

            #region  检测输入
            bool flag      = false;
            var  controls1 = this.Controls.Find("txt", true);
            foreach (var c in controls1)
            {
                if (c is TextBox)
                {
                    var cc = c as TextBox;
                    if (!string.IsNullOrWhiteSpace(cc.Text))
                    {
                        flag = true;
                    }
                }
            }


            if (!flag)
            {
                MessageEx.ShowWarning("请输入号码的金额");
                return;
            }

            if (this.cbox.SelectedIndex == 0)
            {
                MessageEx.ShowWarning("请选择客户");
                return;
            }

            if (string.IsNullOrWhiteSpace(txtIssue.Text))
            {
                MessageEx.ShowWarning("请输入期号");
                return;
            }
            if (txtIssue.Text.Trim().Length != 7)
            {
                MessageEx.ShowWarning("请输入正确的期号");
                return;
            }
            #endregion


            var list  = new List <OrderTM>();
            var index = 0;
            foreach (var c in controls1)
            {
                if (c is TextBox)
                {
                    var cc = c as TextBox;
                    if (!string.IsNullOrWhiteSpace(cc.Text))
                    {
                        OrderTM O = new OrderTM();
                        O.Id        = Guid.NewGuid().ToString("N");
                        O.OrderId   = OrderId;
                        O.InMoney   = Convert.ToDecimal(cc.Text);
                        O.Flag      = 1;
                        O.ChildType = int.Parse(cc.Tag.ToString());
                        O.Status    = (int)ResultStatus.Wait;

                        var Code = this.Controls.Find("code", true).FirstOrDefault(x => x.Tag == c.Tag);
                        if (Code != null)
                        {
                            var lbCode = Code as Label;
                            O.Code = lbCode.Tag.ToString();
                            index  = index + 1;
                        }
                        else
                        {
                            continue;
                        }
                        O.Remarks = Code.Text;
                        O.Sort    = index;
                        var PL = this.Controls.Find("pl", true).FirstOrDefault(x => x.Tag == c.Tag);
                        if (PL != null)
                        {
                            var lbPL = PL as Label;
                            O.Odds = Convert.ToDecimal(lbPL.Text);
                        }
                        else
                        {
                            continue;
                        }
                        O.OutMoney = O.Odds * O.InMoney;
                        list.Add(O);
                    }
                }
            }

            Order <OrderTM> order = new Order <OrderTM>()
            {
                Create_Time     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                Create_User_Id  = "0",
                Customer_Id     = cbox.SelectedValue.ToString().ToTryInt(),
                Id              = OrderId,
                IsDel           = 0,
                Issue           = txtIssue.Text.Trim(),
                Order_No        = ServiceNum.GetOrderNo(),
                Order_Type      = (int)OrderType.大小单双,
                Total_In_Money  = list.Sum(x => x.InMoney),
                Total_Out_Money = 0,
                Update_Time     = "",
                Update_User_Id  = "",
                OrderDetails    = list
            };

            Frm.fmConfirmOther fmConfigm = new fmConfirmOther();
            fmConfigm.InitForm(order);
            if (fmConfigm.ShowDialog() == DialogResult.OK)
            {
                OrderImpl services = new OrderImpl();
                if (services.AddOrderTM(order).Code == 0)
                {
                    MessageBox.Show("成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.None);
                    btnReset_Click(sender, e);
                }
                else
                {
                    MessageBox.Show("失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.None);
                }
            }
        }