Ejemplo n.º 1
0
        private void btnPurchase_Click(object sender, EventArgs e)
        {
            var frm = new frmMarkSixSpecifiedLocationPurchase();

            byte location = 1;

            if (!byte.TryParse(cboNumberLocation.Text, out location) || location < 1 || location > 7)
            {
                MessageBox.Show("请选择1-7的号码位置!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboNumberLocation.Focus();
                return;
            }
            var times = cboTimes.Text;

            if (string.IsNullOrWhiteSpace(times))
            {
                MessageBox.Show("期次不能为空!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cboTimes.Focus();
                return;
            }

            var numbers = new byte[] { 3, 6, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 88, 99 }.ToList();
            var purchasesString = string.Join(";", numbers.Select(a => a.ToString() + ":"));

            var purchase = new MarkSixSpecifiedLocationPurchase {
                Times = times, Location = location, PurchaseList = purchasesString
            };

            frm.MarkSixSpecifiedLocationPurchase = purchase;
            frm.Text = string.Format("第{0}期第{0}位 号码清单", times, location);
            try
            {
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    frmMdi.tsslInfo.Text      = "保存购买成功!";
                    frmMdi.tsslInfo.BackColor = Color.Green;
                    var frmPurchaseRecord = FormHelper.OpenForm <frmMarkSixSpecifiedLocationPurchaseRecord>(frmMdi);
                }
                else
                {
                    frmMdi.tsslInfo.Text      = "取消购买";
                    frmMdi.tsslInfo.BackColor = Color.Yellow;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("生成购买时,发生错误:" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                frmMdi.tsslInfo.Text      = "购买失败";
                frmMdi.tsslInfo.BackColor = Color.Red;
                return;
            }
        }
Ejemplo n.º 2
0
        private void PurchaseUpdate(string id)
        {
            var service = new MarkSixPurchaseService();

            try
            {
                var recordId = long.Parse(id);

                var frm      = new frmMarkSixSpecifiedLocationPurchase();
                var purchase = service.GetSpecifiedLocationPurchaseById(recordId);
                if (purchase == null)
                {
                    throw new Exception(string.Format("错误,购买记录不存在!(Id:{0})", id));
                }
                frm.MarkSixSpecifiedLocationPurchase = purchase;
                frm.Text = string.Format("编辑 第{0}期第{0}位 购买记录", purchase.Times, purchase.Location);

                if (frm.ShowDialog() == DialogResult.OK)
                {
                    Search();
                    frmMdi.tsslInfo.Text      = "修改成功!";
                    frmMdi.tsslInfo.BackColor = Color.Yellow;
                }
                else
                {
                    frmMdi.tsslInfo.Text      = "取消修改";
                    frmMdi.tsslInfo.BackColor = Color.Yellow;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("修改Id:{0}的购买记录失败!{1}", id, ex.Message), "修改失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                frmMdi.tsslInfo.Text      = "修改失败!";
                frmMdi.tsslInfo.BackColor = Color.Red;
            }
        }