コード例 #1
0
ファイル: AddCoupon.cs プロジェクト: freedomwork/playground
        private void btn_Ok_Click(object sender, EventArgs e)
        {
            if (!CheckInput())
                return;

            VipSoft.Model.Coupon coupon = new Model.Coupon();
            VipSoft.BLL.Coupon bllCoupon = new BLL.Coupon();
            coupon.Title = this.textBox_Title.Text.Trim();
            coupon.Prefix = this.textBox_Prefix.Text.Trim();
            coupon.Money = decimal.Parse(this.textBox_Money.Text.Trim());
            coupon.Num = int.Parse(this.textBox_Num.Text.Trim());
            coupon.Type = this.radioButton_TypeOne.Checked ? 0 : 1;
            coupon.StartTime = this.dateTimePicker1.Value;
            coupon.EndTime = this.dateTimePicker2.Value;
            coupon.ShopIDInfo=GetShopIDs();
            coupon.Remark = this.textBox_Remark.Text;
            int CouponID=bllCoupon.Add(coupon);
            if (CouponID>0)
            {
                VipSoft.BLL.CouponDetail bllCouponDetail = new BLL.CouponDetail();
                for (int i = 0; i < coupon.Num; i++)
                {
                    VipSoft.Model.CouponDetail modelCouponDetail = new Model.CouponDetail();
                    modelCouponDetail.CouponID = CouponID;
                    modelCouponDetail.CouponNumber = RandomCouponCode(this.textBox_Prefix.Text.Trim());
                    modelCouponDetail.State = 0;
                    bllCouponDetail.Add(modelCouponDetail);
                }
            }

            MessageBox.Show("增加电子券成功!");

            ClearFormText();
        }
コード例 #2
0
ファイル: Coupon.cs プロジェクト: freedomwork/playground
        private void toolStripButton_Item_Click(object sender, EventArgs e)
        {
            ToolStripButton item = (ToolStripButton)sender;
            switch (item.Name)
            {
                case "AddBtn":
                    AddCoupon addCoupon = new AddCoupon();
                    addCoupon.ShowDialog();
                    break;
                case "DelBtn":
                    if (this.dataGridView_CouponList.SelectedRows.Count != 1)
                        return;

                    int ID = int.Parse(this.dataGridView_CouponList.SelectedRows[0].Cells[0].Value.ToString());
                    DialogResult dRes = MessageBox.Show("您确定要删除此优惠券么?此操作不可恢复。", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                    if (dRes == DialogResult.No)
                        return;
                    VipSoft.BLL.Coupon bllCoupon = new BLL.Coupon();
                    VipSoft.BLL.CouponDetail bllCouponDetail = new BLL.CouponDetail();
                    if (bllCoupon.Delete(ID))
                    {
                        DataSet ds = bllCouponDetail.GetList("CouponID=" + ID.ToString());
                        string IDs = string.Empty;
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            IDs += dr["ID"].ToString() + ",";
                        }
                        if (!string.IsNullOrEmpty(IDs))
                        {
                            IDs = IDs.Substring(0, IDs.Length - 1);
                            bllCouponDetail.DeleteList(IDs);
                        }

                        MessageBox.Show("电子优惠券删除成功!");
                        BindList();
                    }
                    else
                    {
                        MessageBox.Show("删除失败!");
                    }
                    break;
                default:
                    break;
            }
        }