Пример #1
0
        private void toolStripLuu_Click_1(object sender, System.EventArgs e)
        {
            var         pbh = PhieuBanBLL.SelectTop(int.Parse(comboBoxPhieuBan.Text), 0).FirstOrDefault();
            PhieuNo_DTO p   = new PhieuNo_DTO()
            {
                SoPhieuNo     = int.Parse(txtSoPhieuNo.Text),
                SoPhieuBan    = int.Parse(comboBoxPhieuBan.Text),
                NgayNo        = dateTimePickerNgayNo.Value.ToShortDateString(),
                NgayThanhToan = dateTimePickerNgayThanhToan.Value.ToShortDateString(),
                SoTienTra     = txtSoTienTra.Text == "" ? 0 : decimal.Parse(txtSoTienTra.Text),
                SoTienConLai  = txtConLai.Text == "" ? 0 : decimal.Parse(txtConLai.Text)
            };

            if (Edit == 0)
            {
                if (pbh.SoTienTra == pbh.TongTien)
                {
                    MessageBox.Show("Phiếu bán này đã được trả đủ.");
                    return;
                }
                PhieuNoBLL.Insert(p);
            }
            if (Edit == 1)
            {
                PhieuNoBLL.Insert(p);
            }
            if (Edit == 2)
            {
                PhieuNoBLL.Update(p);
            }
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }
Пример #2
0
        private void toolStripSửa_Click(object sender, EventArgs e)
        {
            try
            {
                DataGridViewRow r = datagridviewPhieuNo.SelectedRows[0];
                PhieuNo_DTO     p = new PhieuNo_DTO()
                {
                    SoPhieuNo     = int.Parse(r.Cells["SoPhieuNo"].Value.ToString()),
                    SoPhieuBan    = int.Parse(r.Cells["SoPhieuBan"].Value.ToString()),
                    NgayNo        = r.Cells["NgayNo"].Value.ToString(),
                    NgayThanhToan = r.Cells["NgayThanhToan"].Value.ToString(),
                    SoTienTra     = decimal.Parse(r.Cells["SoTienTra"].Value.ToString()),
                    SoTienConLai  = decimal.Parse(r.Cells["SoTienConLai"].Value.ToString())
                };
                M_PhieuNoEdit form = new M_PhieuNoEdit(p);
                form.Text = "CHỈNH SỬA THÔNG TIN PHIẾU NỢ";

                DialogResult dr = form.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    loadgridview(this.PhieuNo.SelectTop(0));
                }
            }
            catch (Exception)
            {
                //MessageBox.Show(e.ToString() + "\nNếu chưa chọn dòng nào hãy chọn 1 dòng");
            }
        }
Пример #3
0
        public M_PhieuNoEdit(PhieuNo_DTO p) // update
        {
            Edit = 2;
            InitializeComponent();

            txtSoPhieuNo.Text        = p.SoPhieuNo.ToString();
            txtSoPhieuNo.Enabled     = false;
            comboBoxPhieuBan.Text    = p.SoPhieuBan.ToString();
            comboBoxPhieuBan.Enabled = false;

            dateTimePickerNgayNo.Text        = p.NgayNo;
            dateTimePickerNgayThanhToan.Text = p.NgayThanhToan;
            txtSoTienTra.Text = p.SoTienTra.ToString();
            txtConLai.Text    = p.SoTienConLai.ToString();
        }
Пример #4
0
        public void Update(PhieuNo_DTO x)
        {
            PHIEUNO phieuno = datacontext.PHIEUNOs.Where(p => p.SoPhieuNo == x.SoPhieuNo).FirstOrDefault();

            if (phieuno != null)
            {
                phieuno.SoPhieuNo     = x.SoPhieuNo;
                phieuno.SoPhieuBan    = x.SoPhieuBan;
                phieuno.NgayNo        = DateTime.Parse(x.NgayNo);
                phieuno.NgayThanhToan = DateTime.Parse(x.NgayThanhToan);
                phieuno.SoTienTra     = x.SoTienTra;
                phieuno.SoTienConLai  = x.SoTienConLai;
            }

            datacontext.SubmitChanges();
        }
Пример #5
0
        public void Insert(PhieuNo_DTO x)
        {
            PHIEUNO phieuno = new PHIEUNO()
            {
                SoPhieuNo     = x.SoPhieuNo,
                SoPhieuBan    = x.SoPhieuBan,
                NgayNo        = DateTime.Parse(x.NgayNo),
                NgayThanhToan = DateTime.Parse(x.NgayThanhToan),
                SoTienTra     = x.SoTienTra,
                SoTienConLai  = x.SoTienConLai
            };

            datacontext.PHIEUNOs.InsertOnSubmit(phieuno);

            datacontext.SubmitChanges();
        }