private void NhapKho_Load(object sender, EventArgs e) { listCTPN = new BindingList <CTPHIEUNHAP>(); phieu = new PHIEUNHAP(); tbl_nk.DataSource = listCTPN; tb_Manv.Text = MainMenu.usrId.ToString(); col_source = new AutoCompleteStringCollection(); DoChoiBus dcBus = new DoChoiBus(); listDc = dcBus.dsDoChoi(); foreach (DOCHOI a in listDc) { col_source.Add(a.MADC.ToString()); } tb_masp.AutoCompleteMode = AutoCompleteMode.SuggestAppend; tb_masp.AutoCompleteCustomSource = col_source; tb_masp.AutoCompleteSource = AutoCompleteSource.CustomSource; tbl_nk.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; now = DateTime.Now; tb_NgayNhap.Text = now.ToString("dd - MM - yyyy"); PhieuNhapBus phBus = new PhieuNhapBus(); phieu.MANV = MainMenu.usrId; phieu.NGAYNHAP = now; phieu.TONGGIA = 0; tb_SL.Text = "0"; tb_TSL.Text = tong_sl.ToString(); tb_tong_tien.Text = tong_giatri.ToString(); }
private void setDefaultValue() { tb_NnHd.Text = Hd.NGAYHD.ToString("dd - MM - yyyy"); tb_GioHd.Text = Hd.NGAYHD.ToString("hh : mm : ss"); tb_slSP.Text = "1"; cb_masp.Text = ""; col_source = new AutoCompleteStringCollection(); DoChoiBus dcBus = new DoChoiBus(); List <DOCHOI> data = dcBus.dsDoChoi(); foreach (DOCHOI a in data) { col_source.Add(a.MADC.ToString()); } cb_masp.AutoCompleteMode = AutoCompleteMode.SuggestAppend; cb_masp.AutoCompleteCustomSource = col_source; cb_masp.AutoCompleteSource = AutoCompleteSource.CustomSource; tb_Sl.Text = so_sp.ToString(); tb_tong_tien.Text = tien_tong.ToString(); tb_khach_tra.Text = tien_tong.ToString(); tb_tien_du.Text = tien_du.ToString(); tbl_sp.Refresh(); }
private void bt_Luu_Click(object sender, EventArgs e) { if (listCTPN.Count < 1) { return; } try { if (listDc.Count > 0) { DoChoiBus dcbus = new DoChoiBus(); dcbus.AddDSDoChoi(listDc); } PhieuNhapBus phBus = new PhieuNhapBus(); phieu.TONGGIA = double.Parse(tb_tong_tien.Text); phBus.AddPhieuNhap(phieu, listCTPN.ToList <CTPHIEUNHAP>()); MessageBox.Show("Nhập thành công!! \n Locked all Changes!"); this.Dispose(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void tbl_CtHd_CellValueChanged(object sender, EventArgs e) { CTHD ct = new CTHD(); DoChoiBus dcBus = new DoChoiBus(); var row = tbl_CtHd.SelectedRows[0]; ct.MAHD = (int)row.Cells[0].Value; ct.MADC = (int)row.Cells[1].Value; ct.SL = (int)row.Cells[2].Value; ct.GIA = dcBus.DochoiById(ct.MADC).GIA *ct.SL; row.Cells[3].Value = ct.GIA; var li = changedItem.Where(i => (i.MAHD == ct.MAHD && i.MADC == ct.MADC)); if (li.Count() > 0) { li.First().GIA = ct.GIA; li.First().SL = ct.SL; } else { changedItem.Add(ct); } data_change = true; }
private void btn_nhap_Click(object sender, EventArgs e) { if (locked) { return; } try { if (string.IsNullOrEmpty(tb_masp.Text) || string.IsNullOrEmpty(tb_tenDC.Text) || int.Parse(tb_SL.Text) == 0 || string.IsNullOrEmpty(tb_SL.Text)) { MessageBox.Show("Thiếu Dữ Liệu!"); return; } CTPHIEUNHAP ct = new CTPHIEUNHAP(); if (!masp_avail) { DoChoiBus dcBus = new DoChoiBus(); DOCHOI dc = new DOCHOI(); dc.MADC = int.Parse(tb_masp.Text); dc.SL = int.Parse(tb_SL.Text);//edit dc.SL=0; dc.GIA = double.Parse(tb_GiaBan.Text); //listNewDC.Add(dc); } ///<summary> ///hậu ///</summary> CTPHIEUNHAP ctph = new CTPHIEUNHAP(); ctph.MAPHIEU = phieu.MAPHIEU; ctph.MADC = int.Parse(tb_masp.Text); ctph.SL = int.Parse(tb_SL.Text); ctph.GIANHAP = double.Parse(tb_GiaNhap.Text) * (double)ctph.SL; tong_giatri += (double)ctph.GIANHAP; tong_sl += (int)ctph.SL; var li = listCTPN.Where(i => i.MADC == ctph.MADC); if (li.Count() > 0) { li.First().SL += ctph.SL; li.First().GIANHAP += ctph.GIANHAP; } else { listCTPN.Add(ctph); } refreshDataGrid(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void bt_Luu_Click(object sender, EventArgs e) { if (!luu_status) { try { if (!(listDC.Count > 0)) { return; } HoaDonBus hdBus = new HoaDonBus(); Hd.TRIGIA = tien_tong; hdBus.edit(Hd); CTHDBus ctBus = new CTHDBus(); DoChoiBus dcBus = new DoChoiBus(); CTHD ct = new CTHD(); //*/ foreach (DOCHOI it in listDC) { ct.MADC = it.MADC; ct.MAHD = Hd.MAHD; ct.SL = it.SL; ct.GIA = it.GIA; ctBus.addCTHD(ct); }//*/ dcBus.reduceDCs(listDC.ToList <DOCHOI>()); luu_status = true; MessageBox.Show("Lưu thành công!"); } catch (Exception ex) { MessageBox.Show(ex.Message); Console.WriteLine(ex.ToString()); } } else { MessageBox.Show("Dữ liệu đã lưu, Bạn không có quyền sửa!"); } }
private void btn_Sua_Click(object sender, EventArgs e) { try { if (tbl_DsDc.SelectedRows.Count > 0) { if (data_change_status) { DoChoiBus dcBus = new DoChoiBus(); DOCHOI dc = new DOCHOI(); dc.MADC = (int)tbl_DsDc.SelectedRows[0].Cells["MADC"].Value; dc.TENDC = tb_TenDC.Text; if (string.IsNullOrEmpty(tb_Loai.Text)) { dc.LOAI = tb_Loai.Text; } dc.GIA = double.Parse(tb_Gia.Text); if (string.IsNullOrEmpty(tb_NuocSX.Text)) { dc.NUOCSX = tb_NuocSX.Text; } dc.SL = int.Parse(tb_SL.Text); dcBus.editDC(dc); ThongKeKho_Load(sender, e); MessageBox.Show("Đã sửa thành công!!"); } else { MessageBox.Show("Chưa có thông tin đc thay đổi!!"); } } else { MessageBox.Show("Bạn chưa chọn Hàng để sửa!!"); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); MessageBox.Show(ex.Message); } }
private void bt_Nhap_Click(object sender, EventArgs e) { try { DoChoiBus dcBus = new DoChoiBus(); DOCHOI dc = new DOCHOI(); dc = dcBus.DochoiById(int.Parse(cb_masp.Text)); dc.SL = int.Parse(tb_slSP.Text); dc.GIA = ((double)dc.GIA * (double)dc.SL); bool c = true; foreach (DOCHOI i in listDC) { if (dc.MADC == i.MADC) { i.SL += dc.SL; i.GIA += dc.GIA; c = false; break; } } if (c) { listDC.Add(dc); } so_sp += (int)dc.SL; tien_tong += ((double)dc.GIA); setDefaultValue(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void ThongKeKho_Load(object sender, EventArgs e) { DoChoiBus dcBus = new DoChoiBus(); listDc = new List <DOCHOI>(); listDc = dcBus.dsDoChoi(); tbl_DsDc.DataSource = listDc; tbl_DsDc.Refresh(); tbl_DsDc.ClearSelection(); tb_TenDC.Clear(); tb_Loai.Clear(); tb_NuocSX.Clear(); tb_Gia.Clear(); tb_SL.Clear(); if (nvbs.NhanVienByID(manv).MACV != "AD") { btn_Sua.Hide(); btn_Xoa.Hide(); } }
private void btn_Xoa_Click(object sender, EventArgs e) { try { if (tbl_DsDc.SelectedRows.Count > 0) { DoChoiBus dcBus = new DoChoiBus(); dcBus.deleteDC((int)tbl_DsDc.SelectedRows[0].Cells["MADC"].Value); ThongKeKho_Load(sender, e); MessageBox.Show("Đã xóa!!"); } else { MessageBox.Show("Bạn chưa chọn Hàng để xóa!!"); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); MessageBox.Show(ex.Message); } }
private void btn_Xem_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(tb_MaDC.Text)) { try { DoChoiBus dcBus = new DoChoiBus(); listDc = dcBus.DSDoChoibyID(int.Parse(tb_MaDC.Text)); tbl_DsDc.DataSource = listDc; tbl_DsDc.Refresh(); tbl_DsDc.ClearSelection(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); MessageBox.Show(ex.Message); } } else { ThongKeKho_Load(sender, e); } }
private void btn_nhap_Click(object sender, EventArgs e) { if (locked) { return; } try { if (string.IsNullOrEmpty(tb_masp.Text) || string.IsNullOrEmpty(tb_tenDC.Text) || int.Parse(tb_SL.Text) == 0 || string.IsNullOrEmpty(tb_SL.Text)) { MessageBox.Show("Thiếu Dữ Liệu!"); return; } CTPHIEUNHAP ct = new CTPHIEUNHAP(); if (masp_avail == false) { DoChoiBus dcBus = new DoChoiBus(); DOCHOI dc = new DOCHOI(); dc.MADC = int.Parse(tb_masp.Text); dc.SL = int.Parse(tb_SL.Text);//edit dc.SL=0; dc.GIA = double.Parse(tb_GiaBan.Text); dc.LOAI = tb_loai.Text; dc.NUOCSX = tb_ncsx.Text; dc.TENDC = tb_tenDC.Text; // dcBus.AddDoChoi(dc); listDc.Add(dc); ct.MADC = dc.MADC; ct.MAPHIEU = phieu.MAPHIEU; ct.SL = (int)dc.SL; ct.GIANHAP = double.Parse(tb_GiaNhap.Text) * (double)ct.SL; listCTPN.Add(ct); } else { masp_avail = true; var li = listCTPN.Where(i => i.MADC == ct.MADC); if (li.Count() > 0) { li.First().SL += ct.SL; li.First().GIANHAP += ct.GIANHAP; } ct.MADC = int.Parse(tb_masp.Text); ct.MAPHIEU = phieu.MAPHIEU; ct.SL = int.Parse(tb_SL.Text); ct.GIANHAP = double.Parse(tb_GiaNhap.Text) * (double)ct.SL; listCTPN.Add(ct); } ///<summary> ///hậu ///</summary> //CTPHIEUNHAP ctph = new CTPHIEUNHAP(); //ctph.MAPHIEU = phieu.MAPHIEU; //ctph.MADC = int.Parse(tb_masp.Text); //ctph.SL = int.Parse(tb_SL.Text); //ctph.GIANHAP = double.Parse(tb_GiaNhap.Text) * (double)ctph.SL; //tong_giatri += (double)ctph.GIANHAP; //tong_sl += (int)ctph.SL; //var li = listCTPN.Where(i => i.MADC == ctph.MADC); //if (li.Count() > 0) //{ // li.First().SL += ctph.SL; // li.First().GIANHAP += ctph.GIANHAP; //} //else // listCTPN.Add(ctph); tong_giatri += (double)ct.GIANHAP; tong_sl += (int)ct.SL; refresh(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }