public bool KiemTraGoiHang(Entities.ChiTietDonDatHang chitietdonhang) { bool kiemtra = false; Entities.GoiHang[] goihang = new BizLogic.GoiHang().Select(); for (int i = 0; i < goihang.Length; i++) { if (goihang[i].MaGoiHang == chitietdonhang.MaHangHoa) { Entities.HienThi_ChiTiet_DonDatHang row = new Entities.HienThi_ChiTiet_DonDatHang(); row.MaHangHoa = chitietdonhang.MaHangHoa; row.TenHangHoa = goihang[i].TenGoiHang; row.SoLuongDat = chitietdonhang.SoLuong; row.GiaGoc = chitietdonhang.DonGia; row.Giabanbuon = goihang[i].GiaBanBuon; row.Giabanle = goihang[i].GiaBanLe; row.PhanTramChietKhau = chitietdonhang.PhanTramChietKhau; row.Thuegiatrigiatang = "0"; ar.Add(row); kiemtra = true; break; } } return(kiemtra); }
/// <summary> /// lay hang hóa theo ma hang hoa /// </summary> /// <param name="giatri"></param> /// <returns></returns> public Entities.HienThi_ChiTiet_DonDatHang sp_LayHangHoaTheoMaHangHoa(Entities.HienThi_ChiTiet_DonDatHang giatri) { Entities.HienThi_ChiTiet_DonDatHang data = null; try { data = new BizLogic.HangHoaGoiHang().Select(giatri.MaHangHoa); //string sql = "exec sp_LayHangHoaTheoMaHangHoa @MaHangHoa"; //conn = new Connection(); //cn = conn.openConnection(); //cmd = new SqlCommand(sql, cn); //cmd.Parameters.Add("MaHangHoa", SqlDbType.NVarChar, 50).Value = giatri.MaHangHoa; //dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); //while (dr.Read()) //{ // data.MaHangHoa = dr[0].ToString(); // data.TenHangHoa = dr[1].ToString(); // data.SoLuongDat = 1; // data.GiaGoc = dr[2].ToString(); // data.GiaNhap = dr[2].ToString(); // data.Giabanbuon = dr[3].ToString(); // data.Giabanle = dr[4].ToString(); // data.PhanTramChietKhau = "0"; // data.Thuegiatrigiatang = dr[5].ToString(); // data.ChietKhau = "0"; //} } catch (Exception ex) { string s = ex.Message.ToString(); data = null; } return(data); }
public bool KiemTraGoiHang(Entities.ChiTietDonDatHang chitietdonhang) { bool kiemtra = false; Entities.GoiHang[] goihang = new BizLogic.GoiHang().Select(); for (int i = 0; i < goihang.Length; i++) { if (goihang[i].MaGoiHang == chitietdonhang.MaHangHoa) { Entities.HienThi_ChiTiet_DonDatHang row = new Entities.HienThi_ChiTiet_DonDatHang(); row.MaHangHoa = chitietdonhang.MaHangHoa; row.TenHangHoa = goihang[i].TenGoiHang; row.SoLuongDat = chitietdonhang.SoLuong; row.GiaGoc = chitietdonhang.DonGia; row.Giabanbuon = goihang[i].GiaBanBuon; row.Giabanle = goihang[i].GiaBanLe; row.PhanTramChietKhau = chitietdonhang.PhanTramChietKhau; row.Thuegiatrigiatang = "0"; ar.Add(row); kiemtra = true; break; } } return kiemtra; }
public Entities.HienThi_ChiTiet_DonDatHang[] SelectChiTietDonHang(string madonhang) { Entities.HienThi_ChiTiet_DonDatHang[] dh2 = null; Entities.ChiTietDonDatHang[] donhang = new BizLogic.ChiTietDonDatHang().sp_LayBang_ChiTietDonDatHang(); for (int i = 0; i < donhang.Length; i++) { if (donhang[i].MaDonDatHang == madonhang) { this.KiemTraHangHoa(donhang[i]); this.KiemTraGoiHang(donhang[i]); } } int n = ar.Count; if (n == 0) { dh2 = null; } dh2 = new Entities.HienThi_ChiTiet_DonDatHang[n]; for (int i = 0; i < n; i++) { dh2[i] = (Entities.HienThi_ChiTiet_DonDatHang)ar[i]; } return(dh2); }
public Entities.HienThi_ChiTiet_DonDatHang Select(string mahang) { Entities.HienThi_ChiTiet_DonDatHang data = null; try { Entities.GoiHang[] goi = new BizLogic.GoiHang().Select(); Entities.HangHoa[] hanghoa = new BizLogic.HangHoa().Select(); if (goi != null) { for (int k = 0; k < goi.Length; k++) { if (goi[k].MaGoiHang.ToUpper() == mahang.ToUpper()) { data = new Entities.HienThi_ChiTiet_DonDatHang(); data.MaHangHoa = goi[k].MaGoiHang; data.TenHangHoa = goi[k].TenGoiHang; data.SoLuongDat = 1; data.GiaGoc = goi[k].GiaNhap; data.GiaNhap = goi[k].GiaNhap; data.Giabanbuon = goi[k].GiaBanBuon; data.Giabanle = goi[k].GiaBanLe; data.PhanTramChietKhau = "0"; data.Thuegiatrigiatang = "0"; data.ChietKhau = "0"; break; } } } if (hanghoa != null) { for (int k = 0; k < hanghoa.Length; k++) { if (hanghoa[k].MaHangHoa.ToUpper() == mahang.ToUpper()) { data = new Entities.HienThi_ChiTiet_DonDatHang(); data.MaHangHoa = hanghoa[k].MaHangHoa; data.TenHangHoa = hanghoa[k].TenHangHoa; data.SoLuongDat = 1; data.GiaGoc = hanghoa[k].GiaNhap; data.GiaNhap = hanghoa[k].GiaNhap; data.Giabanbuon = hanghoa[k].GiaBanBuon; data.Giabanle = hanghoa[k].GiaBanLe; data.PhanTramChietKhau = "0"; data.Thuegiatrigiatang = Thue(hanghoa[k].MaThueGiaTriGiaTang); data.ChietKhau = "0"; break; } } } } catch (Exception ex) { string s = ex.Message.ToString(); data = null; } return(data); }
/// <summary> /// khoi tao gia tri /// </summary> public HienThi_ChiTiet_DonDatHang() { dh = null; Sql = null; conn = null; cmd = null; arr = null; dr = null; hienthi = null; cn = null; ar = new ArrayList(); }
/// <summary> /// thong tin hoa don nhap /// </summary> /// <param name="giatri"></param> /// <returns></returns> public Entities.HienThi_ChiTiet_DonDatHang[] sp_LayBang_ThongTinHoaDonNhap(Entities.HienThi_ChiTiet_DonDatHang giatri) { Entities.HienThi_ChiTiet_DonDatHang[] arrC = null; try { Constants.HienThi_ChiTiet_DonDatHang dh = new Constants.HienThi_ChiTiet_DonDatHang(); Sql = new Constants.Sql(); string sql = "exec sp_ThongTinHienThiHoaDonNhap @MaHoaDonNhap,@MaKho"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaHoaDonNhap", SqlDbType.VarChar, 20).Value = giatri.MaHangHoa; cmd.Parameters.Add("MaKho", SqlDbType.VarChar, 20).Value = giatri.TenHangHoa; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); Entities.HienThi_ChiTiet_DonDatHang hienthi = null; while (dr.Read()) { hienthi = new Entities.HienThi_ChiTiet_DonDatHang(); hienthi.MaHangHoa = dr[0].ToString().ToUpper(); hienthi.TenHangHoa = "" + dr[1].ToString(); hienthi.SoLuongDat = int.Parse(0 + dr[2].ToString()); hienthi.GiaGoc = Double.Parse(0 + dr[3].ToString()).ToString(); hienthi.Giabanbuon = Double.Parse(0 + dr[4].ToString()).ToString(); hienthi.Giabanle = Double.Parse(0 + dr[5].ToString()).ToString(); hienthi.PhanTramChietKhau = Double.Parse(0 + dr[6].ToString()).ToString(); hienthi.Thuegiatrigiatang = Double.Parse(0 + dr[7].ToString()).ToString(); hienthi.Ngayhethan = new Common.Utilities().XuLy(2, dr[8].ToString()); arr.Add(hienthi); } int n = arr.Count; if (n == 0) { return(null); } arrC = new Entities.HienThi_ChiTiet_DonDatHang[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.HienThi_ChiTiet_DonDatHang)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return(arrC); }
public Entities.HienThi_ChiTiet_DonDatHang[] SelectChiTietDonHang(string madonhang) { Entities.HienThi_ChiTiet_DonDatHang[] dh2 = null; Entities.ChiTietDonDatHang[] donhang = new BizLogic.ChiTietDonDatHang().sp_LayBang_ChiTietDonDatHang(); for (int i = 0; i < donhang.Length; i++) { if (donhang[i].MaDonDatHang == madonhang) { this.KiemTraHangHoa(donhang[i]); this.KiemTraGoiHang(donhang[i]); } } int n = ar.Count; if (n == 0) { dh2 = null; } dh2 = new Entities.HienThi_ChiTiet_DonDatHang[n]; for (int i = 0; i < n; i++) { dh2[i] = (Entities.HienThi_ChiTiet_DonDatHang)ar[i]; } return dh2; }
/// <summary> /// /// </summary> //int bienchay = 0; private void NewRow() { try { //if (bienchay > 1000) //{ // return; //} //for (int i = bienchay; i < bienchay + 100; i++) //{ // toolStrip_txtTracuu.Text = "HH" + i; // toolStrip_txtTenhang.Text = "hàng hóa " + i; // toolStrip_txtSoluong.Text = "100"; // toolStrip_txtGiagoc.Text = "100"; #region Run //try //{ // QuyDoi(toolStrip_txtTracuu.Text.ToUpper()); //} //catch //{ } ////////////////////////////MRK FIX //Kiểm tra bảng quy đổi đơn vị tính bool QUYDOI = false; List<Entities.QuyDoiDonViTinh> lDVT = this.dsQuyDoiDonViTinh; Entities.QuyDoiDonViTinh lDVTSelect = new Entities.QuyDoiDonViTinh(); foreach (Entities.QuyDoiDonViTinh item in lDVT) { if (item.MaHangQuyDoi.Equals(toolStrip_txtTracuu.Text)) { //MaHang = item.MaHangDuocQuyDoi; //tạm thời chuyển mã hàng về mã hàng được quy đổi để lấy thông tin lDVTSelect = item; //biến tạm QUYDOI = true; //trạng thái mã hàng đang nhập vào là hàng quy đổi hay không? break; } } if (QUYDOI) { string txtTraCuuTEM = lDVTSelect.MaHangDuocQuyDoi; string txtSoLuongTEM = (float.Parse(toolStrip_txtSoluong.Text) * lDVTSelect.SoLuongDuocQuyDoi).ToString(); //toolStrip_txtTracuu.Text = lDVTSelect.MaHangDuocQuyDoi; //try //{ // toolStrip_txtSoluong.Text = (float.Parse(toolStrip_txtSoluong.Text) * lDVTSelect.SoLuongDuocQuyDoi).ToString(); //} //catch { } if (toolStrip_txtTenhang.Text != string.Empty) { if (txtManhacungcap.Text != "") { Entities.HienThi_ChiTiet_DonDatHang add = new Entities.HienThi_ChiTiet_DonDatHang(); add.MaHangHoa = txtTraCuuTEM.ToUpper(); string thongbao = KiemTraMa(add); add.TenHangHoa = toolStrip_txtTenhang.Text; add.SoLuongDat = int.Parse(0 + txtSoLuongTEM); add.GiaGoc = toolStrip_txtGiagoc.Text; add.Giabanbuon = Double.Parse(0 + banbuon).ToString(); add.Giabanle = Double.Parse(0 + banle).ToString(); add.TongTien = (float.Parse(0 + toolStrip_txtGiagoc.Text) * int.Parse(0 + txtSoLuongTEM)).ToString(); add.PhanTramChietKhau = int.Parse(0 + toolStrip_txtChietkhauphantram.Text).ToString(); add.GiaNhap = Double.Parse(toolStrip_txtGianhap.Text).ToString(); add.Thuegiatrigiatang = Double.Parse(0 + toolStrip_txtThuegiatrigiatang.Text).ToString(); add.ChietKhau = float.Parse(0 + toolStrip_Chietkhau.Text).ToString(); Common.Utilities ck = new Common.Utilities(); string ngay = toolStrip_txtNgayhethan.Text; string ngayhientai = this.Date.ToString("dd/MM/yyyy"); if (Utils.StringToDateTime(ngayhientai).Date <= Utils.StringToDateTime(ngay).Date) { add.Ngayhethan = ngay; if (float.Parse(toolStrip_txtGianhap.Text) > 0) { if (thongbao == "NO") { MessageBox.Show("Mã hàng không đúng"); toolStrip_txtTracuu.Focus(); return; } else { LayGiaTri(dgvInsertOrder, add); DoiTen(dgvInsertOrder); ResetTool(); } } else { MessageBox.Show("Kiểm tra giá nhập"); } } else { MessageBox.Show("Kiểm tra lại định dạng ngày hết hạn <dd/MM/yyyy>"); } } else { ResetTool(); MessageBox.Show("Chọn nhà cung cấp"); return; } } else { MessageBox.Show("Phải nhập hàng hóa"); return; } } //////////////////////////////////// else {//Không Quy Đổi if (toolStrip_txtTenhang.Text != string.Empty) { if (txtManhacungcap.Text != "") { Entities.HienThi_ChiTiet_DonDatHang add = new Entities.HienThi_ChiTiet_DonDatHang(); add.MaHangHoa = toolStrip_txtTracuu.Text.ToUpper(); string thongbao = KiemTraMa(add); add.TenHangHoa = toolStrip_txtTenhang.Text; add.SoLuongDat = int.Parse(0 + toolStrip_txtSoluong.Text); add.GiaGoc = toolStrip_txtGiagoc.Text; add.Giabanbuon = Double.Parse(0 + banbuon).ToString(); add.Giabanle = Double.Parse(0 + banle).ToString(); add.TongTien = (float.Parse(0 + toolStrip_txtGiagoc.Text) * int.Parse(0 + toolStrip_txtSoluong.Text)).ToString(); add.PhanTramChietKhau = int.Parse(0 + toolStrip_txtChietkhauphantram.Text).ToString(); add.GiaNhap = Double.Parse(toolStrip_txtGianhap.Text).ToString(); add.Thuegiatrigiatang = Double.Parse(0 + toolStrip_txtThuegiatrigiatang.Text).ToString(); add.ChietKhau = float.Parse(0 + toolStrip_Chietkhau.Text).ToString(); Common.Utilities ck = new Common.Utilities(); string ngay = toolStrip_txtNgayhethan.Text; string ngayhientai = this.Date.ToString("dd/MM/yyyy"); bool _kq0 = true; bool _kq1 = true; DateTime ngay1 = Utils.StringToDateTime(ngayhientai, out _kq0); //DateTime.Parse(new Common.Utilities().KiemTraDinhDangNgayThangNam("ThangNgayNam", ngayhientai, '/')); DateTime ngay2 = Utils.StringToDateTime(ngay, out _kq1); //DateTime.Parse(new Common.Utilities().KiemTraDinhDangNgayThangNam("ThangNgayNam", ngay, '/')); if (!_kq1 || !_kq0 || !(ngay1.Date <= ngay2.Date)) { MessageBox.Show("Kiểm tra lại định dạng ngày hết hạn <dd/MM/yyyy>"); } else { add.Ngayhethan = ngay; if (float.Parse(toolStrip_txtGianhap.Text) > 0) { if (thongbao == "NO") { MessageBox.Show("Mã hàng không đúng"); toolStrip_txtTracuu.Focus(); return; } else { LayGiaTri(dgvInsertOrder, add); DoiTen(dgvInsertOrder); } } else MessageBox.Show("Kiểm tra giá nhập"); } } else { MessageBox.Show("Chọn nhà cung cấp"); return; } } else { MessageBox.Show("Phải nhập hàng hóa"); return; } } #endregion //} //bienchay += 100; } catch (Exception ex) { string s = ex.ToString(); Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = lay; MessageBox.Show("Kiểm tra ngày nhập"); } }
private void DoDuLieu(Entities.HoaDonNhap dat) { try { Common.Utilities com = new Common.Utilities(); ID = dat.HoaDonNhapID; txtSodonhang.Text = dat.MaHoaDonNhap; txtManhacungcap.Text = dat.MaNhaCungCap; ////////////////////////////////////////MRK FIX if (lblTenNhaCungCap.Text.Equals("")) { try { cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); Entities.TruyenGiaTri cc = new Entities.TruyenGiaTri("Select", ""); clientstrem = cl.SerializeObj(this.client, "ThongTinNhaCungCap", cc); Entities.ThongTinNhaCungCap[] ddh = new Entities.ThongTinNhaCungCap[1]; ddh = (Entities.ThongTinNhaCungCap[])cl.DeserializeHepper(clientstrem, ddh); client.Close(); clientstrem.Close(); if (ddh.Length > 0) { foreach (Entities.ThongTinNhaCungCap item in ddh) { if (item.Manhacungcap.Equals(txtManhacungcap.Text)) { lblTenNhaCungCap.Text = item.Tennhacungcap; } } } else { } } catch { } } ///////////////////////////////////////////////////////// GiaTriCanLuu.Ma = dat.MaNhaCungCap; makNgaydonhang.Text = new Common.Utilities().XuLy(2, dat.NgayNhap.ToString()); makHanthanhtoan.Text = new Common.Utilities().XuLy(2, dat.HanThanhToan.ToString()); txtNohienthoi.Text = dat.NoHienThoi; txtnguoigiaohang.Text = dat.NguoiGiaoHang; cbxHinhthucthanhtoan.SelectedItem = dat.HinhThucThanhToan; cbxKhoHang.SelectedValue = dat.MaKho; maKhoHang = dat.MaKho; txtMadondathang.Text = dat.MaDonDatHang; cbxTienTe_TyGia.SelectedValue = dat.MaTienTe; txtDiengiai.Text = dat.GhiChu; if (dat.MaDonDatHang != "" || dat.MaDonDatHang == "<F4 - TRA CỨU>") { chekChonLoai.Checked = true; } else { chekChonLoai.Checked = false; } txtMadondathang.ReadOnly = true; btnTimMadatmuahang.Enabled = false; chekChonLoai.Enabled = false; if (txtSodonhang.Text != "" || txtSodonhang.Text != "<F4 -Tra cứu>") { HienThi_ChiTiet_HoaDonNhap(txtSodonhang.Text); } else { Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = null; dgvInsertOrder.DataSource = lay; DoiTen(dgvInsertOrder); } double ckTongHoaDon = 0; if (!string.IsNullOrEmpty(dat.ChietKhau)) ckTongHoaDon = double.Parse(dat.ChietKhau); txtTienCKTM0.Text = new Common.Utilities().FormatMoney(ckTongHoaDon); TinhToan(); txtCKTM0.Text = new Common.Utilities().FormatMoney(100 - (1 - double.Parse(dat.ChietKhau) / double.Parse(txtTongThanhToan.Text.Replace(",", ""))) * 100); txtTongThanhToan.Text = new Common.Utilities().FormatMoney(double.Parse(txtTongThanhToan.Text.Replace(",", "")) - double.Parse(txtTienCKTM0.Text.Replace(",", ""))); txtThanhtoanngay.Text = new TienIch().FormatMoney(dat.ThanhToanNgay); txtTienTraLai.Text = new Common.Utilities().FormatMoney(Double.Parse(dat.ThanhToanNgay) - Double.Parse(dat.TongTien)); double thanhtoankhilapphieu = Double.Parse(dat.ThanhToanSauKhiLapPhieu); if ((Double.Parse(txtThanhtoanngay.Text.Replace(",", "")) + thanhtoankhilapphieu) == Double.Parse(txtTongThanhToan.Text)) { lbtinhtrang.Text = "Đã Thanh Toán"; toolStripStatus_Thanhtoan.Enabled = false; } else { lbtinhtrang.Text = "Chưa Thanh Toán"; toolStripStatus_Thanhtoan.Enabled = true; } string date = new Common.Utilities().MyDateConversion(makNgaydonhang.Text); string date2 = new Common.Utilities().MyDateConversion(makHanthanhtoan.Text); string makho = cbxKhoHang.SelectedValue.ToString(); string matt = cbxTienTe_TyGia.SelectedValue.ToString(); hoa = new Entities.HoaDonNhap[1]; hoa[0] = dat; } catch (Exception ex) { string s = ex.Message; Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = null; dgvInsertOrder.DataSource = lay; DoiTen(dgvInsertOrder); } }
/// <summary> /// thong tin hoa don nhap /// </summary> /// <param name="giatri"></param> /// <returns></returns> public Entities.HienThi_ChiTiet_DonDatHang[] sp_LayBang_ThongTinHoaDonNhap(Entities.HienThi_ChiTiet_DonDatHang giatri) { Entities.HienThi_ChiTiet_DonDatHang[] arrC = null; try { Constants.HienThi_ChiTiet_DonDatHang dh = new Constants.HienThi_ChiTiet_DonDatHang(); Sql = new Constants.Sql(); string sql = "exec sp_ThongTinHienThiHoaDonNhap @MaHoaDonNhap,@MaKho"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); cmd.Parameters.Add("MaHoaDonNhap", SqlDbType.VarChar, 20).Value = giatri.MaHangHoa; cmd.Parameters.Add("MaKho", SqlDbType.VarChar, 20).Value = giatri.TenHangHoa; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); arr = new ArrayList(); Entities.HienThi_ChiTiet_DonDatHang hienthi = null; while (dr.Read()) { hienthi = new Entities.HienThi_ChiTiet_DonDatHang(); hienthi.MaHangHoa = dr[0].ToString().ToUpper(); hienthi.TenHangHoa = "" + dr[1].ToString(); hienthi.SoLuongDat = int.Parse(0 + dr[2].ToString()); hienthi.GiaGoc = Double.Parse(0 + dr[3].ToString()).ToString(); hienthi.Giabanbuon = Double.Parse(0 + dr[4].ToString()).ToString(); hienthi.Giabanle = Double.Parse(0 + dr[5].ToString()).ToString(); hienthi.PhanTramChietKhau = Double.Parse(0 + dr[6].ToString()).ToString(); hienthi.Thuegiatrigiatang = Double.Parse(0 + dr[7].ToString()).ToString(); hienthi.Ngayhethan = new Common.Utilities().XuLy(2, dr[8].ToString()); arr.Add(hienthi); } int n = arr.Count; if (n == 0) { return null; } arrC = new Entities.HienThi_ChiTiet_DonDatHang[n]; for (int i = 0; i < n; i++) { arrC[i] = (Entities.HienThi_ChiTiet_DonDatHang)arr[i]; } } catch (Exception ex) { string s = ex.Message.ToString(); } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return arrC; }
private void button1_Click(object sender, EventArgs e) { try { if (chekChonLoai.Checked == true) { ngaythangnam = "KhongCo"; if (hanhdong == "Insert") { if (txtManhacungcap.Text != "<F4 -Tra cứu>" && txtManhacungcap.Text != "") { GiaTriCanLuu.Ma = null; GiaTriCanLuu.Ten = null; GiaTriCanLuu.Giatri = null; dgvInsertOrder.DataSource = null; Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = lay; DoiTen(dgvInsertOrder); reset(); frmTraCuu fr = new frmTraCuu("HoaDonNhap_MaDonDatHang", "MaDonDatHang", txtManhacungcap.Text); fr.ShowDialog(); BindHangHoa(); if (GiaTriCanLuu.Ma.Length <= 0) { txtMadondathang.Text = "<F4 -Tra cứu>"; } if (dgvInsertOrder.RowCount > 0) { TinhToan(); txtTienTraLai.Text = "0"; } else { reset(); } ngaythangnam = ""; } else { MessageBox.Show("Nhập mã nhà cung cấp"); } } } } catch { } }
private void chekChonLoai_CheckedChanged(object sender, EventArgs e) { try { dgvInsertOrder.DataSource = null; Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = lay; DoiTen(dgvInsertOrder); format(); } catch { } }
public Entities.HienThi_ChiTiet_DonDatHang Select(string mahang) { Entities.HienThi_ChiTiet_DonDatHang data = null; try { Entities.GoiHang[] goi = new BizLogic.GoiHang().Select(); Entities.HangHoa[] hanghoa = new BizLogic.HangHoa().Select(); if (goi!=null) { for (int k = 0; k < goi.Length; k++) { if (goi[k].MaGoiHang.ToUpper() == mahang.ToUpper()) { data = new Entities.HienThi_ChiTiet_DonDatHang(); data.MaHangHoa = goi[k].MaGoiHang; data.TenHangHoa = goi[k].TenGoiHang; data.SoLuongDat = 1; data.GiaGoc = goi[k].GiaNhap; data.GiaNhap = goi[k].GiaNhap; data.Giabanbuon = goi[k].GiaBanBuon; data.Giabanle = goi[k].GiaBanLe; data.PhanTramChietKhau = "0"; data.Thuegiatrigiatang = "0"; data.ChietKhau = "0"; break; } } } if (hanghoa!=null) { for (int k = 0; k < hanghoa.Length; k++) { if (hanghoa[k].MaHangHoa.ToUpper() == mahang.ToUpper()) { data = new Entities.HienThi_ChiTiet_DonDatHang(); data.MaHangHoa = hanghoa[k].MaHangHoa; data.TenHangHoa = hanghoa[k].TenHangHoa; data.SoLuongDat = 1; data.GiaGoc = hanghoa[k].GiaNhap; data.GiaNhap = hanghoa[k].GiaNhap; data.Giabanbuon = hanghoa[k].GiaBanBuon; data.Giabanle = hanghoa[k].GiaBanLe; data.PhanTramChietKhau = "0"; data.Thuegiatrigiatang = Thue(hanghoa[k].MaThueGiaTriGiaTang); data.ChietKhau = "0"; break; } } } } catch (Exception ex) { string s = ex.Message.ToString(); data = null; } return data; }
private void frmXuLyNhapKho_Load(object sender, EventArgs e) { try { this.GetDate(); frmXuLyNhapKho fr = new frmXuLyNhapKho(); this.cbxHinhthucthanhtoan.Items.AddRange(new object[] { "Tiền mặt", "ATM" }); if (hanhdong == "Insert") { Common.Utilities ck = new Common.Utilities(); string ngay = this.Date.ToString("dd/MM/yyyy"); makNgaydonhang.Text = ngay; makHanthanhtoan.Text = ngay; cbxHinhthucthanhtoan.SelectedIndex = 0; toolStrip_txtNgayhethan.Text = this.Date.ToString("dd/MM/yyyy"); toolStripStatus_Themmoi.Enabled = true; Application.OpenForms[fr.Name].Text = "Thêm đơn nhập kho - F3 Thanh toán - F6 sửa hàng hóa - F9 Sửa giá hàng hóa"; Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = null; dgvInsertOrder.DataSource = lay; DoiTen(dgvInsertOrder); toolStrip_txtTracuu.Focus(); format(); if (Double.Parse(txtThanhtoanngay.Text.Replace(",", "")) == Double.Parse(txtTongThanhToan.Text) && (txtThanhtoanngay.Text.Replace(",", "") != "0")) { lbtinhtrang.Visible = true; lbtinhtrang.Text = "Đã thanh toán"; toolStripStatus_Thanhtoan.Enabled = false; } else { if (txtTongThanhToan.Text == "0" || txtTongThanhToan.Text == "00") { lbtinhtrang.Visible = true; lbtinhtrang.Text = "Chưa thanh toán"; toolStripStatus_Thanhtoan.Enabled = true; } else { lbtinhtrang.Visible = true; lbtinhtrang.Text = "Chưa thanh toán hết"; toolStripStatus_Thanhtoan.Enabled = true; } } getID("HoaDonNhap"); txtSodonhang.Text = makiemtra; toolStripStatus_Thanhtoan.Enabled = false; toolStripStatus_In.Enabled = false; } new Common.Utilities().ComboxKhoHang(cbxKhoHang); LayTenTT(); txtTygia.Text = tigia[0].Giatri2.ToString(); cbxTienTe_TyGia.SelectedIndex = 0; cbxTienTe_TyGia.Enabled = false; if (hanhdong == "Update") { palNhap.Enabled = false; palXem.Enabled = false; Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = null; dgvInsertOrder.DataSource = lay; txtMadondathang.ReadOnly = true; btnTimMadatmuahang.Enabled = false; txtManhacungcap.ReadOnly = true; btnTimnhacungcap.Enabled = false; toolStripStatus_Themmoi.Enabled = false; Application.OpenForms[fr.Name].Text = "Quản lý hóa đơn nhập - Xem hóa đơn nhập <Enter - Thêm hàng hóa, F3 - Thanh toán - F9 Sửa giá hàng hóa>"; DoDuLieu(this.hoadon); toolStripStatus_In.Enabled = true; } } catch { Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = null; dgvInsertOrder.DataSource = lay; DoiTen(dgvInsertOrder); if (txtSodonhang.Text == "") { txtSodonhang.Text = "HDN_0001"; } } }
private void format() { try { if (chekChonLoai.Checked == false) { Application.OpenForms[this.Name].Text = "Thêm đơn nhập kho - F3 Thanh toán - F6 sửa hàng hóa - F9 sửa giá hàng hóa"; dgvInsertOrder.DataSource = null; Entities.HienThi_ChiTiet_DonDatHang[] row = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = row; txtMadondathang.Text = "<F4 - Tra cứu>"; txtMadondathang.ReadOnly = true; btnTimMadatmuahang.Enabled = false; //toolStrip_btnThem.Enabled = true; toolStrip_txtTracuu.Enabled = true; toolStrip_txtSoluong.Enabled = true; toolStrip_txtChietkhauphantram.Enabled = true; } if (chekChonLoai.Checked == true) { Application.OpenForms[this.Name].Text = "Thêm đơn nhập kho - F3 Thanh toán - F9 Sửa giá hàng hóa"; txtMadondathang.ReadOnly = false; btnTimMadatmuahang.Enabled = true; //toolStrip_btnThem.Enabled = false; toolStrip_txtTracuu.Enabled = false; toolStrip_txtSoluong.Enabled = false; toolStrip_txtChietkhauphantram.Enabled = false; } toolStrip_txtTracuu.Text = ""; toolStrip_txtSoluong.Text = "1"; toolStrip_txtChietkhauphantram.Text = "0"; toolStrip_txtTenhang.Text = ""; toolStrip_txtGianhap.Text = "0"; toolStrip_txtGiagoc.Text = "0"; toolStrip_txtThuegiatrigiatang.Text = "0"; toolStrip_txtNgayhethan.Text = this.Date.ToString("dd/MM/yyyy"); DoiTen(dgvInsertOrder); } catch (Exception ex) { string s = ex.Message; } }
/// <summary> /// sua ngay /// </summary> /// <param name="dgv"></param> private void getData(DataGridView dgv) { try { ArrayList arr = new ArrayList(); Entities.HienThi_ChiTiet_DonDatHang[] list = null; if (dgv.RowCount > 0 && i >= 0) { toolStrip_txtTracuu.Text = dgv[1, i].Value.ToString(); toolStrip_txtTenhang.Text = dgv[2, i].Value.ToString(); toolStrip_txtSoluong.Text = Double.Parse(0 + dgv[3, i].Value.ToString()).ToString(); toolStrip_txtGiagoc.Text = Double.Parse(0 + dgv[4, i].Value.ToString()).ToString(); banbuon = Double.Parse(0 + dgv[5, i].Value.ToString()).ToString(); banle = Double.Parse(0 + dgv[6, i].Value.ToString()).ToString(); toolStrip_txtChietkhauphantram.Text = "0"; toolStrip_txtThuegiatrigiatang.Text = Double.Parse(0 + dgv[8, i].Value.ToString()).ToString(); giatrigiatang = Double.Parse(0 + dgv[8, i].Value.ToString()).ToString(); toolStrip_Chietkhau.Text = "0"; toolStrip_txtGianhap.Text = (Double.Parse(0 + dgv[4, i].Value.ToString()) * int.Parse(toolStrip_txtSoluong.Text)).ToString(); date = dgv[12, i].Value.ToString(); if (date.Length <= 0) { date = toolStrip_txtNgayhethan.Text = this.Date.ToString("dd/MM/yyyy"); } toolStrip_txtNgayhethan.Text = date; } else { toolStrip_txtNgayhethan.Text = new Common.Utilities().XuLy(2, date); list = new Entities.HienThi_ChiTiet_DonDatHang[0]; arr = null; dgv.DataSource = list; } DoiTen(dgv); } catch (Exception ex) { string s = ex.Message; Entities.HienThi_ChiTiet_DonDatHang[] list = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgv.DataSource = list; DoiTen(dgv); } }
private HangHoa LayHangHoaTheoMa(HangHoa input) { try { string maHang = input.MaHangHoa; QuyDoiDonViTinh lDvtSelect; if (CheckQuyDoiDonViTinh(maHang, out lDvtSelect)) { return new HangHoa(); //tạm bỏ #region có quy đổi Entities.HienThi_ChiTiet_DonDatHang ktm = new Entities.HienThi_ChiTiet_DonDatHang(); cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); ktm = new Entities.HienThi_ChiTiet_DonDatHang("Select", lDvtSelect.MaHangDuocQuyDoi); clientstrem = cl.SerializeObj(this.client, "LayHangHoaTheoMaHangHoa", ktm); Entities.HienThi_ChiTiet_DonDatHang tra = new Entities.HienThi_ChiTiet_DonDatHang(); tra = (Entities.HienThi_ChiTiet_DonDatHang)cl.DeserializeHepper(clientstrem, tra); if (tra.MaHangHoa == null || tra == null) { toolStrip_txtTracuu.Focus(); frmXuLyHangHoa frm = new frmXuLyHangHoa("ThemNhapKho", lDvtSelect.MaHangDuocQuyDoi); frm.ShowDialog(); ResetTool(); toolStrip_txtTracuu.Text = GiaTriCanLuu.mahanghoa; //LayHangHoaTheoMa(toolStrip_txtTracuu.Text); } else { toolStrip_txtTracuu.Text = lDvtSelect.MaHangQuyDoi; if (lDvtSelect.TenHangDuocQuyDoi.Equals("")) { toolStrip_txtTenhang.Text = lDvtSelect.MaHangQuyDoi; } else { toolStrip_txtTenhang.Text = lDvtSelect.TenHangDuocQuyDoi; } if (tra.SoLuongDat != null && tra.SoLuongDat > 0) { if (lDvtSelect.SoLuongDuocQuyDoi != null || lDvtSelect.SoLuongDuocQuyDoi > 0) { try { toolStrip_txtSoluong.Text = (tra.SoLuongDat / lDvtSelect.SoLuongDuocQuyDoi).ToString(); } catch { } } } ////toolStrip_txtSoluong.Text = tra.SoLuongDat.ToString(); toolStrip_txtGiagoc.Text = tra.GiaGoc; banbuon = tra.Giabanbuon; banle = tra.Giabanle; giatrigiatang = tra.Thuegiatrigiatang; toolStrip_txtChietkhauphantram.Text = tra.PhanTramChietKhau; toolStrip_txtThuegiatrigiatang.Text = int.Parse(0 + tra.Thuegiatrigiatang).ToString(); toolStrip_txtGianhap.Text = tra.GiaNhap; toolStrip_txtNgayhethan.Text = this.Date.ToString("dd/MM/yyyy"); toolStrip_txtSoluong.Text = ""; toolStrip_txtSoluong.Focus(); } #endregion } else { #region không có quy đổi cl = new Server_Client.Client(); client = cl.Connect(Luu.IP, Luu.Ports); HangHoa temp = new HangHoa { HanhDong = "SelectHangHoa_Theo_MaHangHoa", MaHangHoa = maHang }; clientstrem = cl.SerializeObj(client, "HangHoa", temp); HangHoa[] hh1 = new HangHoa[1]; hh1 = (HangHoa[])cl.DeserializeHepper1(clientstrem, hh1); if (hh1 == null || hh1.Length == 0) return new HangHoa(); return hh1[0]; #endregion } } catch { } return new Entities.HangHoa(); }
/// <summary> /// Tìm chi tiết hàng hóa và fill dữ liệu vào form /// </summary> /// <param name="maHang"></param> private void LayHangHoaTheoMa(string maHang) { try { QuyDoiDonViTinh lDvtSelect; if (CheckQuyDoiDonViTinh(maHang, out lDvtSelect)) { #region có quy đổi HienThi_ChiTiet_DonDatHang ktm = new HienThi_ChiTiet_DonDatHang(); cl = new Server_Client.Client(); client = cl.Connect(Luu.IP, Luu.Ports); ktm = new HienThi_ChiTiet_DonDatHang("Select", lDvtSelect.MaHangDuocQuyDoi); clientstrem = cl.SerializeObj(client, "LayHangHoaTheoMaHangHoa", ktm); HienThi_ChiTiet_DonDatHang tra = new HienThi_ChiTiet_DonDatHang(); tra = (HienThi_ChiTiet_DonDatHang)cl.DeserializeHepper(clientstrem, tra); if (tra == null) { toolStrip_txtTracuu.Focus(); frmXuLyHangHoa frm = new frmXuLyHangHoa("ThemNhapKho", lDvtSelect.MaHangDuocQuyDoi); frm.ShowDialog(); ResetTool(); toolStrip_txtTracuu.Text = GiaTriCanLuu.mahanghoa; //LayHangHoaTheoMa(toolStrip_txtTracuu.Text); } else { toolStrip_txtTracuu.Text = lDvtSelect.MaHangQuyDoi; toolStrip_txtTenhang.Text = string.IsNullOrEmpty(lDvtSelect.TenHangDuocQuyDoi) ? lDvtSelect.MaHangQuyDoi : lDvtSelect.TenHangDuocQuyDoi; toolStrip_txtSoluong.Text = tra.SoLuongDat > 0 && lDvtSelect.SoLuongDuocQuyDoi > 0 ? (tra.SoLuongDat / lDvtSelect.SoLuongDuocQuyDoi).ToString() : string.Empty; toolStrip_txtGiagoc.Text = tra.GiaGoc; banbuon = tra.Giabanbuon; banle = tra.Giabanle; giatrigiatang = tra.Thuegiatrigiatang; toolStrip_txtChietkhauphantram.Text = tra.PhanTramChietKhau; toolStrip_txtThuegiatrigiatang.Text = int.Parse(0 + tra.Thuegiatrigiatang).ToString(); toolStrip_txtGianhap.Text = tra.GiaNhap; toolStrip_txtNgayhethan.Text = Date.ToString("dd/MM/yyyy"); toolStrip_txtSoluong.Text = ""; toolStrip_txtSoluong.Focus(); } #endregion } else { #region không có quy đổi HienThi_ChiTiet_DonDatHang ktm = new Entities.HienThi_ChiTiet_DonDatHang(); cl = new Server_Client.Client(); client = cl.Connect(Luu.IP, Luu.Ports); ktm = new HienThi_ChiTiet_DonDatHang("Select", maHang); clientstrem = cl.SerializeObj(client, "LayHangHoaTheoMaHangHoa", ktm); HienThi_ChiTiet_DonDatHang tra = new HienThi_ChiTiet_DonDatHang(); tra = (HienThi_ChiTiet_DonDatHang)cl.DeserializeHepper(clientstrem, tra); if (tra == null) { toolStrip_txtTracuu.Focus(); frmXuLyHangHoa frm = new frmXuLyHangHoa("ThemNhapKho", toolStrip_txtTracuu.Text); frm.ShowDialog(); ResetTool(); toolStrip_txtTracuu.Text = GiaTriCanLuu.mahanghoa; } else { toolStrip_txtTracuu.Text = tra.MaHangHoa; toolStrip_txtTenhang.Text = tra.TenHangHoa; toolStrip_txtSoluong.Text = tra.SoLuongDat.ToString(); toolStrip_txtGiagoc.Text = tra.GiaGoc; banbuon = tra.Giabanbuon; banle = tra.Giabanle; giatrigiatang = tra.Thuegiatrigiatang; toolStrip_txtChietkhauphantram.Text = tra.PhanTramChietKhau; toolStrip_txtThuegiatrigiatang.Text = int.Parse(0 + tra.Thuegiatrigiatang).ToString(); toolStrip_txtGianhap.Text = tra.GiaNhap; toolStrip_txtNgayhethan.Text = Date.ToString("dd/MM/yyyy"); toolStrip_txtSoluong.Text = ""; toolStrip_txtSoluong.Focus(); } #endregion } } catch { } }
private void HienThi_ChiTiet_HoaDonNhap(string Mahoadonnhap) { try { Entities.HienThi_ChiTiet_DonDatHang dat = new Entities.HienThi_ChiTiet_DonDatHang(); dat.HanhDong = "Select"; dat.MaHangHoa = Mahoadonnhap; dat.TenHangHoa = maKhoHang; cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); clientstrem = cl.SerializeObj(this.client, "HienThi_ChiTiet_HoaDonNhap", dat); Entities.HienThi_ChiTiet_DonDatHang[] ddh = new Entities.HienThi_ChiTiet_DonDatHang[1]; ddh = (Entities.HienThi_ChiTiet_DonDatHang[])cl.DeserializeHepper(clientstrem, ddh); client.Close(); clientstrem.Close(); if (ddh.Length > 0 && ddh != null) { XuLyChiTietDonDatHang(ddh); } else { Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = null; dgvInsertOrder.DataSource = lay; DoiTen(dgvInsertOrder); } } catch (Exception ex) { string s = ex.Message; Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = null; dgvInsertOrder.DataSource = lay; DoiTen(dgvInsertOrder); } }
/// <summary> /// do du lieu vao dgv /// </summary> private void HienThi_ChiTiet_DonDatHang() { try { Entities.TruyenGiaTri dat = new Entities.TruyenGiaTri(); dat.Hanhdong = "Select"; dat.Giatritruyen = txtMadondathang.Text; cl = new Server_Client.Client(); this.client = cl.Connect(Luu.IP, Luu.Ports); clientstrem = cl.SerializeObj(this.client, "HienThi_ChiTiet_DonDatHang", dat); Entities.HienThi_ChiTiet_DonDatHang[] ddh = new Entities.HienThi_ChiTiet_DonDatHang[1]; ddh = (Entities.HienThi_ChiTiet_DonDatHang[])cl.DeserializeHepper(clientstrem, ddh); client.Close(); clientstrem.Close(); if (ddh.Length > 0) { XuLyChiTietDonDatHang(ddh); } else { Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = lay; DoiTen(dgvInsertOrder); } } catch (Exception ex) { string s = ex.Message.ToString(); Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = lay; DoiTen(dgvInsertOrder); } }
private void getDataTable(DataGridView dgv) { try { ArrayList arr = new ArrayList(); Entities.HienThi_ChiTiet_DonDatHang[] list = null; if (dgv.RowCount > 0 && i >= 0) { toolStrip_txtTracuu.Text = dgv[1, i].Value.ToString(); toolStrip_txtTenhang.Text = dgv[2, i].Value.ToString(); toolStrip_txtSoluong.Text = int.Parse(0 + dgv[3, i].Value.ToString()).ToString(); toolStrip_txtGiagoc.Text = Double.Parse(0 + dgv[4, i].Value.ToString()).ToString(); banbuon = Double.Parse(0 + dgv[5, i].Value.ToString()).ToString(); banle = Double.Parse(0 + dgv[6, i].Value.ToString()).ToString(); toolStrip_txtChietkhauphantram.Text = "0"; toolStrip_txtThuegiatrigiatang.Text = Double.Parse(0 + dgv[8, i].Value.ToString()).ToString(); giatrigiatang = Double.Parse(0 + dgv[8, i].Value.ToString()).ToString(); toolStrip_Chietkhau.Text = "0"; toolStrip_txtGianhap.Text = (Double.Parse(0 + dgv[4, i].Value.ToString()) * int.Parse(toolStrip_txtSoluong.Text)).ToString(); //date = new Common.Utilities().KiemTraDinhDangNgayThangNam("NgayThangNam", dgv[12, i].Value.ToString(), '/'); date = dgv[12, i].Value.ToString(); if (date.Length <= 0) { date = toolStrip_txtNgayhethan.Text = DateServer.Date().ToString("dd/MM/yyyy"); } toolStrip_txtNgayhethan.Text = date; for (int j = 0; j < dgv.RowCount; j++) { if (dgv[1, j].Value.ToString() != dgv[1, i].Value.ToString()) { Entities.HienThi_ChiTiet_DonDatHang row = new Entities.HienThi_ChiTiet_DonDatHang(); row.MaHangHoa = dgv.Rows[j].Cells[1].Value.ToString(); row.TenHangHoa = "" + dgv.Rows[j].Cells[2].Value.ToString(); row.SoLuongDat = int.Parse(0 + dgv.Rows[j].Cells[3].Value.ToString()); row.GiaGoc = Double.Parse(0 + dgv.Rows[j].Cells[4].Value.ToString()).ToString(); row.Giabanbuon = Double.Parse(0 + dgv.Rows[j].Cells[5].Value.ToString()).ToString(); row.Giabanle = Double.Parse(0 + dgv.Rows[j].Cells[6].Value.ToString()).ToString(); row.PhanTramChietKhau = Double.Parse(0 + dgv.Rows[j].Cells[7].Value.ToString()).ToString(); row.Thuegiatrigiatang = Double.Parse(0 + dgv.Rows[j].Cells[8].Value.ToString()).ToString(); row.GiaNhap = Double.Parse(0 + dgv.Rows[j].Cells[9].Value.ToString()).ToString(); row.TongTien = Double.Parse(0 + dgv.Rows[j].Cells[11].Value.ToString()).ToString(); row.Ngayhethan = dgv.Rows[j].Cells[12].Value.ToString(); arr.Add(row); } } int n = arr.Count; if (n == 0) { arr = null; } list = new Entities.HienThi_ChiTiet_DonDatHang[n]; for (int x = 0; x < n; x++) { list[x] = (Entities.HienThi_ChiTiet_DonDatHang)arr[x]; } dgv.DataSource = list; } else { toolStrip_txtNgayhethan.Text = new Common.Utilities().XuLy(2, date); list = new Entities.HienThi_ChiTiet_DonDatHang[0]; arr = null; dgv.DataSource = list; } DoiTen(dgv); } catch (Exception ex) { string s = ex.Message; Entities.HienThi_ChiTiet_DonDatHang[] list = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgv.DataSource = list; DoiTen(dgv); } }
private void XuLyChiTietDonDatHang(Entities.HienThi_ChiTiet_DonDatHang[] chitiet) { try { if (chitiet.Length > 0) { Entities.HienThi_ChiTiet_DonDatHang[] giatri = null; ArrayList arr = new ArrayList(); Entities.HienThi_ChiTiet_DonDatHang[] g = new Entities.HienThi_ChiTiet_DonDatHang[chitiet.Length]; for (int i = 0; i < chitiet.Length; i++) { Entities.HienThi_ChiTiet_DonDatHang row = new Entities.HienThi_ChiTiet_DonDatHang(); row.MaHangHoa = chitiet[i].MaHangHoa; row.TenHangHoa = chitiet[i].TenHangHoa; row.SoLuongDat = chitiet[i].SoLuongDat; row.GiaGoc = chitiet[i].GiaGoc; row.Giabanbuon = chitiet[i].Giabanbuon; row.Giabanle = chitiet[i].Giabanle; string phantram = chitiet[i].PhanTramChietKhau; string gianhap = "0"; if (phantram == "0") { gianhap = (Double.Parse(chitiet[i].GiaGoc) * Double.Parse(chitiet[i].SoLuongDat.ToString())).ToString(); } else { gianhap = ((Double.Parse(chitiet[i].GiaGoc) * Double.Parse(chitiet[i].SoLuongDat.ToString())) - ((Double.Parse(chitiet[i].PhanTramChietKhau) / 100 * Double.Parse(chitiet[i].GiaGoc) * Double.Parse(chitiet[i].SoLuongDat.ToString())))).ToString(); } row.PhanTramChietKhau = phantram; row.Thuegiatrigiatang = chitiet[i].Thuegiatrigiatang; row.GiaNhap = gianhap; row.TongTien = (Double.Parse(chitiet[i].GiaGoc) * Double.Parse(chitiet[i].SoLuongDat.ToString())).ToString(); //ngaythangnam = new Common.Utilities().KiemTraDinhDangNgayThangNam("NgayThangNam", chitiet[i].Ngayhethan, '/'); ngaythangnam = chitiet[i].Ngayhethan; row.Ngayhethan = ngaythangnam; arr.Add(row); } int n = arr.Count; if (n == 0) { giatri = null; } giatri = new Entities.HienThi_ChiTiet_DonDatHang[n]; for (int i = 0; i < n; i++) { giatri[i] = (Entities.HienThi_ChiTiet_DonDatHang)arr[i]; } if (giatri != null) { dgvInsertOrder.DataSource = null; dgvInsertOrder.DataSource = giatri; DoiTen(dgvInsertOrder); } else { Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = null; dgvInsertOrder.DataSource = lay; DoiTen(dgvInsertOrder); } } else { dgvInsertOrder.DataSource = chitiet; DoiTen(dgvInsertOrder); } } catch (Exception ex) { string s = ex.Message.ToString(); Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = null; dgvInsertOrder.DataSource = lay; DoiTen(dgvInsertOrder); } }
private void btnTimnhacungcap_Click(object sender, EventArgs e) { try { if (hanhdong == "Insert") { GiaTriCanLuu.Ma = null; GiaTriCanLuu.Ten = null; GiaTriCanLuu.TonKho = null; dgvInsertOrder.DataSource = null; Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgvInsertOrder.DataSource = lay; DoiTen(dgvInsertOrder); reset(); frmTraCuu frm = new frmTraCuu("HoaDonNhap_NhaCungCap", "HoaDonNhap"); frm.ShowDialog(); BindHangHoa(); if (GiaTriCanLuu.Ma == null) { txtManhacungcap.Text = "<F4 -Tra cứu>"; } if (txtNohienthoi.Text.Length <= 0) { txtNohienthoi.Text = "0"; } } } catch { } }
/// <summary> /// cap nhat lai ngay het han /// </summary> /// <param name="dgv"></param> /// <param name="themmoi"></param> private void LuuNgayHetHan(DataGridView dgv, string ma, string ngaymoi) { try { ArrayList arr = new ArrayList(); Entities.HienThi_ChiTiet_DonDatHang[] list = null; if (dgv.RowCount > 0) { int count = dgv.RowCount; list = new Entities.HienThi_ChiTiet_DonDatHang[count]; for (int i = 0; i < count; i++) { Entities.HienThi_ChiTiet_DonDatHang row = new Entities.HienThi_ChiTiet_DonDatHang(); row.MaHangHoa = dgv.Rows[i].Cells[1].Value.ToString().ToUpper(); row.TenHangHoa = dgv.Rows[i].Cells[2].Value.ToString(); row.SoLuongDat = int.Parse(dgv.Rows[i].Cells[3].Value.ToString()); row.GiaGoc = dgv.Rows[i].Cells[4].Value.ToString(); row.Giabanbuon = dgv.Rows[i].Cells[5].Value.ToString(); row.Giabanle = dgv.Rows[i].Cells[6].Value.ToString(); row.PhanTramChietKhau = dgv.Rows[i].Cells[7].Value.ToString(); row.Thuegiatrigiatang = dgv.Rows[i].Cells[8].Value.ToString(); row.TongTien = dgv.Rows[i].Cells[9].Value.ToString(); row.GiaNhap = dgv.Rows[i].Cells[11].Value.ToString(); string ngay = row.Ngayhethan = dgv.Rows[i].Cells[12].Value.ToString(); if (dgv.Rows[i].Cells[1].Value.ToString() == ma) { row.Ngayhethan = ngaymoi; } else { row.Ngayhethan = ngay; } arr.Add(row); } } int n = arr.Count; if (n == 0) { list = null; } list = new Entities.HienThi_ChiTiet_DonDatHang[n]; for (int i = 0; i < n; i++) { list[i] = (Entities.HienThi_ChiTiet_DonDatHang)arr[i]; } if (list != null) { dgv.DataSource = null; dgv.DataSource = list; } else { dgv.DataSource = null; Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgv.DataSource = lay; } DoiTen(dgvInsertOrder); } catch (Exception ex) { string s = ex.Message; dgv.DataSource = null; Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgv.DataSource = lay; DoiTen(dgvInsertOrder); } }
/// <summary> /// hungvv them moi row ============================================================================== /// </summary> public void LayGiaTri(DataGridView dgv, Entities.HienThi_ChiTiet_DonDatHang themmoi) { try { ArrayList arr = new ArrayList(); Entities.HienThi_ChiTiet_DonDatHang[] list = null; if (dgv.RowCount > 0) { int count = dgv.RowCount; list = new Entities.HienThi_ChiTiet_DonDatHang[count]; Boolean check = false; for (int i = 0; i < count; i++) { string sl = "1"; string gn = "0"; string tong = "0"; Entities.HienThi_ChiTiet_DonDatHang row = new Entities.HienThi_ChiTiet_DonDatHang(); row.MaHangHoa = dgv.Rows[i].Cells[1].Value.ToString().ToUpper(); row.TenHangHoa = dgv.Rows[i].Cells[2].Value.ToString(); if (dgv.Rows[i].Cells[1].Value.ToString() == themmoi.MaHangHoa) { sl = (int.Parse(dgv.Rows[i].Cells[3].Value.ToString()) + themmoi.SoLuongDat).ToString(); tong = new Common.Utilities().FormatMoney(Double.Parse(sl) * Double.Parse(dgv.Rows[i].Cells[4].Value.ToString())); gn = new Common.Utilities().FormatMoney((Double.Parse(tong) - ((Double.Parse(dgv.Rows[i].Cells[7].Value.ToString()) / 100 * Double.Parse(dgv.Rows[i].Cells[4].Value.ToString())) * Double.Parse(sl)))); check = true; } else { sl = (Convert.ToInt32(dgv.Rows[i].Cells[3].Value.ToString())).ToString(); tong = dgv.Rows[i].Cells[11].Value.ToString(); gn = dgv.Rows[i].Cells[9].Value.ToString(); } row.SoLuongDat = int.Parse(sl); row.GiaGoc = new Common.Utilities().FormatMoney(Double.Parse(dgv.Rows[i].Cells[4].Value.ToString())); row.Giabanbuon = new Common.Utilities().FormatMoney(Double.Parse(dgv.Rows[i].Cells[5].Value.ToString())); row.Giabanle = new Common.Utilities().FormatMoney(Double.Parse(dgv.Rows[i].Cells[6].Value.ToString())); row.PhanTramChietKhau = dgv.Rows[i].Cells[7].Value.ToString(); row.Thuegiatrigiatang = Double.Parse(0 + dgv.Rows[i].Cells[8].Value.ToString()).ToString(); row.GiaNhap = gn; row.TongTien = tong; row.Ngayhethan = dgv.Rows[i].Cells[12].Value.ToString(); arr.Add(row); } if (check == false) { Entities.HienThi_ChiTiet_DonDatHang row = new Entities.HienThi_ChiTiet_DonDatHang(); row.MaHangHoa = themmoi.MaHangHoa; row.TenHangHoa = themmoi.TenHangHoa; row.SoLuongDat = themmoi.SoLuongDat; row.GiaGoc = new Common.Utilities().FormatMoney(Double.Parse(themmoi.GiaGoc)); row.Giabanbuon = new Common.Utilities().FormatMoney(Double.Parse(themmoi.Giabanbuon)); row.Giabanle = new Common.Utilities().FormatMoney(Double.Parse(themmoi.Giabanle)); row.PhanTramChietKhau = themmoi.PhanTramChietKhau; row.Thuegiatrigiatang = themmoi.Thuegiatrigiatang; row.GiaNhap = new Common.Utilities().FormatMoney(Double.Parse(themmoi.GiaNhap)); row.TongTien = new Common.Utilities().FormatMoney(Double.Parse(themmoi.TongTien)); row.Ngayhethan = themmoi.Ngayhethan; arr.Add(row); } } else { list = new Entities.HienThi_ChiTiet_DonDatHang[1]; Entities.HienThi_ChiTiet_DonDatHang row = new Entities.HienThi_ChiTiet_DonDatHang(); row.MaHangHoa = themmoi.MaHangHoa; row.TenHangHoa = themmoi.TenHangHoa; row.SoLuongDat = themmoi.SoLuongDat; row.GiaGoc = new Common.Utilities().FormatMoney(Double.Parse(themmoi.GiaGoc)); row.Giabanbuon = new Common.Utilities().FormatMoney(Double.Parse(themmoi.Giabanbuon)); row.Giabanle = new Common.Utilities().FormatMoney(Double.Parse(themmoi.Giabanle)); row.PhanTramChietKhau = themmoi.PhanTramChietKhau; row.Thuegiatrigiatang = themmoi.Thuegiatrigiatang; row.GiaNhap = new Common.Utilities().FormatMoney(Double.Parse(themmoi.GiaNhap)); row.TongTien = new Common.Utilities().FormatMoney(Double.Parse(themmoi.TongTien)); row.Ngayhethan = themmoi.Ngayhethan; arr.Add(row); } int n = arr.Count; if (n == 0) { list = null; } list = new Entities.HienThi_ChiTiet_DonDatHang[n]; for (int i = 0; i < n; i++) { list[i] = (Entities.HienThi_ChiTiet_DonDatHang)arr[i]; } if (list != null) { dgv.DataSource = null; dgv.DataSource = list; } else { dgv.DataSource = null; Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgv.DataSource = lay; } } catch (Exception ex) { string s = ex.Message; dgv.DataSource = null; Entities.HienThi_ChiTiet_DonDatHang[] lay = new Entities.HienThi_ChiTiet_DonDatHang[0]; dgv.DataSource = lay; } }