Example #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmAddDonHang f = new frmAddDonHang();

            f.MdiParent = this.MdiParent;
            f.Show();
            this.Dispose();
        }
Example #2
0
        private void gr_btn_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            int intRow = gridView1.FocusedRowHandle;

            if ((intRow >= 0) && (gridView1.GetRowCellValue(intRow, "DonHangID") != null))
            {
                string strDonHangID = gridView1.GetRowCellValue(intRow, "DonHangID").ToString();
                switch (e.Button.Caption.ToUpper())
                {
                case "PRINT":
                    PhieuBanHang rp = new PhieuBanHang();
                    rp.SetDataSource(reportsController.prtDonHang(strDonHangID));
                    rp.Refresh();
                    ThongTinShop shop = ThongTinShopController.GetItem();
                    rp.SetParameterValue("TenShop", shop.TenShop);
                    rp.SetParameterValue("DiaChi", shop.DiaChi);
                    rp.SetParameterValue("SoDienThoai", shop.SoDienThoai);
                    rp.SetParameterValue("WebSite", shop.website);
                    frmViewReports fReport = null;
                    foreach (Form item in MdiChildren)
                    {
                        if (item.GetType() == typeof(frmViewReports))
                        {
                            fReport = (item as frmViewReports);
                            fReport.crystalReportViewer1.ReportSource = rp;
                            fReport.Activate();
                            return;
                        }
                    }
                    fReport = new frmViewReports();
                    fReport.crystalReportViewer1.ReportSource = rp;
                    fReport.MdiParent = this.MdiParent;
                    fReport.Show();
                    break;

                case "DEL":
                    if (MessageBox.Show("Bạn muốn xóa đơn hàng này", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                    {
                        DonHangController.Del(strDonHangID);
                        gridControl1.DataSource = DonHangController.GetAllList();
                    }
                    break;

                case "VIEW":
                    DonHang viewItem = DonHangController.GetItem(strDonHangID);
                    if (viewItem != null)
                    {
                        frmAddDonHang f = new frmAddDonHang();
                        f.ViewItem  = viewItem;
                        f.forMode   = "view";
                        f.MdiParent = this.MdiParent;
                        f.Show();
                        this.Dispose();
                    }
                    break;

                default:
                    break;
                }
            }
        }