コード例 #1
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;
            }
        }