Exemplo n.º 1
0
        public int Insertphieunhaphang(Phieunhaphang phieunhaphang)
        {
            string sql = string.Format("Insert into Phieunhaphang(Maphieuthu,MaNcc,MaNvnhap,MaKhonhap,Ngaynhap,Tongtien) Values('{0}','{1}','{2}','{3}','{4}','{5}')", phieunhaphang.Maphieuthu, phieunhaphang.MaNcc, phieunhaphang.Manv, phieunhaphang.Makho, phieunhaphang.Ngaylap, phieunhaphang.Tongtien);

            var rs = db.thesuadulieu(sql);

            return(rs);
        }
Exemplo n.º 2
0
        public Phieunhaphang layinfoPXH(string Value)
        {
            Phieunhaphang phieunhaphang = new Phieunhaphang();

            for (int i = 0; i < phieunhaphangs.Count; i++)
            {
                if (phieunhaphangs[i].Maphieuthu == Value)
                {
                    phieunhaphang = phieunhaphangs[i];
                    break;
                }
            }
            return(phieunhaphang);
        }
Exemplo n.º 3
0
        private void GridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            if (e.Column.FieldName == "Maphieuxuathang")
            {
                var Value = gridView1.GetRowCellValue(e.RowHandle, e.Column);
                if (Value.ToString() != "")
                {
                    phienhaphang = layinfoPXH(Value.ToString());
                }
                if (phienhaphang != null)
                {
                    gridView1.SetRowCellValue(e.RowHandle, "Ngaylapphieu", phienhaphang.Ngaylap);
                    gridView1.SetRowCellValue(e.RowHandle, "Tongtienphieuthu", phienhaphang.Tongtien);
                    if (gridView1.GetFocusedRowCellValue(Tientra) == null)
                    {
                        tientra = 0;
                    }
                    else
                    {
                        tientra = Convert.ToDecimal(gridView1.GetFocusedRowCellValue(Tientra));
                        if (phienhaphang.Tongtien < tientra)
                        {
                            MessageBox.Show("Số tiền nhập lớn hơn tiền nợ " + phienhaphang.Tongtien);
                        }
                        else
                        {
                            tongtien = Convert.ToDecimal(gridView1.GetFocusedRowCellValue(Tongtienphieuthu));
                            tienno   = tongtien - tientra;
                            gridView1.SetFocusedRowCellValue(Tienno, tienno);
                        }
                    }
                }
            }

            if (e.Column == Tientra)
            {
                tientra = Convert.ToDecimal(gridView1.GetFocusedRowCellValue(Tientra));
                if (phienhaphang.Tongtien < tientra)
                {
                    MessageBox.Show("Số tiền nhập lớn hơn tiền nợ " + phienhaphang.Tongtien);
                }
                else
                {
                    tongtien = Convert.ToDecimal(gridView1.GetFocusedRowCellValue(Tongtienphieuthu));
                    tienno   = tongtien - tientra;
                    gridView1.SetFocusedRowCellValue(Tienno, tienno);
                }
            }
        }
Exemplo n.º 4
0
        private void Btnluu_Click(object sender, EventArgs e)
        {
            Phieunhaphang phieuxuathang = new Phieunhaphang();

            phieuxuathang.Maphieuthu = txtmaphieuchi.Text;
            phieuxuathang.Makho      = int.Parse(cbbkhonhap.EditValue.ToString());
            phieuxuathang.MaNcc      = int.Parse(txtMancc.Text);
            phieuxuathang.Manv       = int.Parse(cbbnhanviennhap.EditValue.ToString());
            phieuxuathang.Ngaylap    = txtngaylap.Text;
            phieuxuathang.Tongtien   = tongtien();
            // chua rang buoc madonhang
            muahangBUS.Insertphieunhaphang(phieuxuathang);

            var id = muahangBUS.IDphieunhaphang(phieuxuathang.Maphieuthu);
            int soluong;
            CTPhieuxuatnhaphang ctPhieuxuathang = new CTPhieuxuatnhaphang();

            for (int i = 0; i < lstphieuxh.Count; i++)
            {
                ctPhieuxuathang.Maphieuxuathang = int.Parse(id.ToString());
                ctPhieuxuathang.Masp            = lstphieuxh[i].Idsp;
                ctPhieuxuathang.SoLuong         = lstphieuxh[i].Soluong;
                ctPhieuxuathang.Dongiahientai   = lstphieuxh[i].Giahientai;
                ctPhieuxuathang.Thanhtien       = lstphieuxh[i].Tongthanhtoan;
                muahangBUS.InsertCTphieuxuathang(ctPhieuxuathang);
                sanpham = laysanphamtheoID(lstphieuxh[i].Idsp);
                soluong = sanpham.SoLuong + lstphieuxh[i].Soluong;
                muahangBUS.UpdateSoluonghang(soluong, lstphieuxh[i].Idsp);
            }
            if (checkin.Checked == true)
            {
                Inphieuthuchi dsnguoidung = new Inphieuthuchi();
                dsnguoidung.DataSource = lstphieuxh;
                ReportPrintTool report = new ReportPrintTool(dsnguoidung);
                dsnguoidung.txttenkhachang.Text     = cbbNCC.Text;
                dsnguoidung.txtkhooxuat.Text        = cbbkhonhap.Text;
                dsnguoidung.txtmaphieuthu.Text      = txtmaphieuchi.Text;
                dsnguoidung.txtngaylap.Text         = txtngaylap.Text;
                dsnguoidung.txtsodienthoai.Text     = txtdienthoai.Text;
                dsnguoidung.txttonggt.Text          = tongtien().ToString();
                dsnguoidung.lbltieude.Text          = "Phiếu nhập hàng";
                dsnguoidung.labelname.Text          = "Nhà cung cấp:";
                dsnguoidung.labelkhoxuatnhap.Text   = "Kho nhập:";
                dsnguoidung.labelnhanvienkyten.Text = "Nhân viên nhập hàng";
                dsnguoidung.labeltonghd.Text        = "Tổng giá trị phiếu chi: thành tiền+thuế GTGT";
                report.ShowPreview();
            }
        }
Exemplo n.º 5
0
 public int Insertphieunhaphang(Phieunhaphang phieunhaphang)
 {
     return(db.Insertphieunhaphang(phieunhaphang));
 }