Exemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                using (var db = new RestaurantManagerDataEntities())
                {
                    int idpnhap  = int.Parse(txtid.Text);
                    var ngaynhap = dtngaynhap.Value;
                    int.TryParse(lueDONGIAO.EditValue.ToString(), out int idgiaohang);
                    int.TryParse(lueStorekeeper.EditValue.ToString(), out int thukho);
                    string thukhoName = lueStorekeeper.Text;
                    string nguoigiao  = txtNguoiGiao.Text;
                    string nguoinhap  = txtNguoiNhan.Text;

                    if (ngaynhap == null)
                    {
                        XtraMessageBox.Show("Bạn chưa chọn ngày nhập!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    if (lstD_PNHAP_ViewModel.Count == 0)
                    {
                        XtraMessageBox.Show("Bạn chưa nhập hàng hóa!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    if (lstD_PNHAP_ViewModel.Count() == 0)
                    {
                        XtraMessageBox.Show("Bạn chưa nhập hàng hóa!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    var model   = new PNHAP_ViewModel();
                    var nameLog = Properties.Settings.Default.NameLog;
                    model.idpnhap       = idpnhap;
                    model.idpgiao       = idgiaohang;
                    model.ngaynhap      = ngaynhap;
                    model.thukho        = thukhoName;
                    model.nguoilapphieu = nameLog;
                    model.nguoigiao     = nameLog;
                    var res = new PNHAPBll().savePNHAP(model, lstD_PNHAP_ViewModel, Properties.Settings.Default.NameLog);
                    if (res != "success")
                    {
                        XtraMessageBox.Show(res, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    XtraMessageBox.Show("Thêm phiếu giao hàng thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var selects = gridView1.GetSelectedRows();
            var row     = gridView1.GetRow(selects[0]);

            if (selects == null)
            {
                XtraMessageBox.Show("Bạn chưa chọn phiếu nhập để xóa!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            var select = (PNHAP)row;
            var result = XtraMessageBox.Show("Bạn có chắc chắn muốn xóa?", "Xác nhận", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                var res = new PNHAPBll().DeletePNHAP(select.idpnhap);
            }
        }
Exemplo n.º 3
0
        private void btnPrint_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                var row = gridView1.FocusedRowHandle;

                var obj = gridView1.GetFocusedRow();
                if (obj == null)
                {
                    return;
                }
                var objData = (PNHAP)obj;
                var master  = new PNHAPBll().GetPNHAPById(objData.idpnhap);
                using (frmPrint frm = new frmPrint())
                {
                    frm.PrintPNHAP(master, master.lstDetail);
                    frm.ShowDialog();
                }
            }
            catch
            {
            }
        }