コード例 #1
0
        private void btnKinhDoanh_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            int    madl  = int.Parse(gridViewDLNgungKD.GetFocusedRowCellValue("MaDaiLy").ToString());
            string tendl = gridViewDLNgungKD.GetFocusedRowCellValue("TenDaiLy").ToString();
            string quan  = gridViewDLNgungKD.GetFocusedRowCellValue("Quan").ToString();

            var tb = MessageBox.Show(string.Format("Bạn có chắc chắn muốn tiếp tục kinh doanh đại lý <{0}> ?", tendl), "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (tb == DialogResult.Yes)
            {
                BUS_DaiLy daily = new BUS_DaiLy();
                var       flag  = daily.TiepTucKinhDoanh(madl, quan);
                if (flag == true)
                {
                    MessageBox.Show(string.Format("Bạn đã tiếp tục kinh doanh đại lý <{0}> thành công.", tendl), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    KhiKinhDoanhLaiDaiLy(EventArgs.Empty);   //  https://msdn.microsoft.com/en-us/library/9aackb16(v=vs.110).aspx
                    this.FormLoad();
                }
                else
                {
                    MessageBox.Show(string.Format("Thao tác không thành công. {0} đã đạt đến số đại lý tối đa.", quan), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                return;
            }
        }