private void button3_Click(object sender, EventArgs e) { int tongtien = 0; for (int i = 0; i < cT_NHAP_SP_DK_LUUKHODataGridView.Rows.Count - 1; i++) { tongtien += (int.Parse(cT_NHAP_SP_DK_LUUKHODataGridView.Rows[i].Cells[3].Value.ToString()) * int.Parse(cT_NHAP_SP_DK_LUUKHODataGridView.Rows[i].Cells[4].Value.ToString())); } if ((textBox4.Text.Length == 0 && textBox6.Text.Length == 0) || (textBox4.Text.Length != 0 && textBox6.Text.Length != 0)) { MessageBox.Show("Vui lòng lựa chọn một trong hai hình thức thanh toán"); } else { //kiem tra tinh trang <= 100 if (textBox6.Text.Length == 0) { if (int.Parse(textBox4.Text) + int.Parse(tinhTrangTTDataGridView1.Rows[0].Cells[1].Value.ToString()) <= 100) { //update tinh trang trong bang tinhtrangTT tinhTrangTTTableAdapter.UpdateQuery(int.Parse(textBox4.Text), int.Parse(textBox3.Text)); //update trang thai trong bang phieu nhap tinhTrangTTTableAdapter.updatetinhtrang(nHAPHANG1DataGridView.CurrentRow.Cells[0].Value.ToString()); MessageBox.Show("Thành Công"); int phantramdatra = int.Parse(textBox4.Text) + int.Parse(tinhTrangTTDataGridView1.Rows[0].Cells[1].Value.ToString()); int phantramconlai = 100 - phantramdatra; int tontienconlaiphaitra = tongtien * phantramconlai / 100; ThongKe thongKe = new ThongKe(); thongKe.xuatfileHD_TragopNCC(tinhTrangTTDataGridView1, (int.Parse(textBox4.Text) * tongtien / 100).ToString(), tontienconlaiphaitra.ToString(), DateTime.Today.ToString(), "hdTG_NCC"); } else { MessageBox.Show("vượt quá số tiền phải trả !!!"); } } else { if (int.Parse(textBox6.Text) + int.Parse(tinhTrangTTDataGridView1.Rows[0].Cells[1].Value.ToString()) <= tongtien) { tinhTrangTTTableAdapter.UpdateQuery(int.Parse(textBox6.Text), int.Parse(textBox3.Text)); //update trang thai trong bang phieu nhap tinhTrangTTTableAdapter.updatetinhtrang(nHAPHANG1DataGridView.CurrentRow.Cells[0].Value.ToString()); MessageBox.Show("Thành Công"); int sotiendatra = int.Parse(textBox6.Text) + int.Parse(tinhTrangTTDataGridView1.Rows[0].Cells[1].Value.ToString()); int sotienconlai = tongtien - sotiendatra; ThongKe thongKe = new ThongKe(); thongKe.xuatfileHD_TragopNCC(tinhTrangTTDataGridView1, textBox6.ToString(), sotienconlai.ToString(), DateTime.Today.ToString(), "hdTG_NCC"); } else { MessageBox.Show("vượt quá số tiền phải trả !!!"); } } } //load data this.tinhTrangTTTableAdapter.Fill(this.tt.TinhTrangTT); this.nHAPHANG1TableAdapter.Fill(this.nghiepVu.NHAPHANG1); }
private void lưuKhoToolStripMenuItem_Click(object sender, EventArgs e) { for (int i = 0; i < cT_NHAP_SP_DK_LUUKHODataGridView.Rows.Count - 1; i++) { //cap nhat kho lINHKIENTableAdapter.Update_SL_LK(int.Parse(cT_NHAP_SP_DK_LUUKHODataGridView.Rows[i].Cells[3].Value.ToString()), cT_NHAP_SP_DK_LUUKHODataGridView.Rows[i].Cells[0].Value.ToString()); } //xuat hd try { this.tAIKHOANTableAdapter.Fill_DK(this.nghiepVu.TAIKHOAN, tendn); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } hOADON_ttTableAdapter.Insert(cT_NHAP_SP_DK_LUUKHODataGridView.Rows[0].Cells[2].Value.ToString(), "MLHD03", DateTime.Today, "temp", hOADON_kttontaiDataGridView.Rows[0].Cells[1].Value.ToString()); nHAPHANG1TableAdapter.UpdateQuery("Đã lưu", nHAPHANGDataGridView.CurrentRow.Cells[0].Value.ToString()); //xuly xuat file pdf int tongtien = 0; int sol = 0; for (int i = 0; i < cT_NHAP_SP_DK_LUUKHODataGridView.RowCount - 1; i++) { sol += int.Parse(cT_NHAP_SP_DK_LUUKHODataGridView.Rows[i].Cells[3].Value.ToString()); tongtien += (int.Parse(cT_NHAP_SP_DK_LUUKHODataGridView.Rows[i].Cells[3].Value.ToString()) * int.Parse(cT_NHAP_SP_DK_LUUKHODataGridView.Rows[i].Cells[4].Value.ToString())); } ThongKe.xuatfile_HD_NhapHang(cT_NHAP_SP_DK_LUUKHODataGridView, cT_NHAP_SP_DK_LUUKHODataGridView.Rows[0].Cells[0].Value.ToString(), tongtien.ToString(), sol.ToString(), DateTime.Now.ToString("dd/MM/yyyy"), "HoaDon_NhapLK"); //==================================== this.nHAPHANG1TableAdapter.Fill(this.nghiepVu.NHAPHANG1); //this.kHOTableAdapter.Fill(this.nghiepVu.KHO); this.lINHKIENTableAdapter.Fill(this.nghiepVu.LINHKIEN); }
private void lưuKhoToolStripMenuItem_Click(object sender, EventArgs e) { try { this.tAIKHOANTableAdapter.Fill_DK(this.nghiepVu.TAIKHOAN, tendn); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } string manv = tAIKHOANDataGridView.Rows[0].Cells[1].Value.ToString(); hOADON_ttTableAdapter.Insert(cT_NHAP_SP_DK_LUUKHODataGridView.Rows[0].Cells[2].Value.ToString(), "MLHD01", DateTime.Today, "temp", manv); try { this.hOADON_kttontaiTableAdapter.Fill(this.tt.HOADON_kttontai, new System.Nullable <System.DateTime>(((System.DateTime)(System.Convert.ChangeType(DateTime.Today, typeof(System.DateTime)))))); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } for (int i = 0; i < cT_NHAP_SP_DK_LUUKHODataGridView.RowCount - 1; i++) { try { this.hOADON_kttontaiTableAdapter.Fill(this.tt.HOADON_kttontai, new System.Nullable <System.DateTime>(((System.DateTime)(System.Convert.ChangeType(DateTime.Today, typeof(System.DateTime)))))); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } string MASP = cT_NHAP_SP_DK_LUUKHODataGridView.Rows[i].Cells[1].Value.ToString(); string sl = cT_NHAP_SP_DK_LUUKHODataGridView.Rows[i].Cells[3].Value.ToString(); kHOTableAdapter.UpdateQuery_sl(int.Parse(sl), MASP, kHOComboBox.SelectedValue.ToString()); if (hOADON_kttontaiDataGridView.Rows[0].Cells[0].Value.ToString() != cT_NHAP_SP_DK_LUUKHODataGridView.Rows[i].Cells[2].Value.ToString()) { hOADON_ttTableAdapter.Insert(cT_NHAP_SP_DK_LUUKHODataGridView.Rows[i].Cells[2].Value.ToString(), "MLHD01", DateTime.Today, "temp", manv); } } nHAPHANG1TableAdapter.UpdateQuery("Đã lưu", nHAPHANGDataGridView.CurrentRow.Cells[0].Value.ToString()); int tongtien = 0; int sol = 0; //xuly xuat file pdf for (int i = 0; i < cT_NHAP_SP_DK_LUUKHODataGridView.RowCount - 1; i++) { sol += int.Parse(cT_NHAP_SP_DK_LUUKHODataGridView.Rows[i].Cells[3].Value.ToString()); tongtien += (int.Parse(cT_NHAP_SP_DK_LUUKHODataGridView.Rows[i].Cells[3].Value.ToString()) * int.Parse(cT_NHAP_SP_DK_LUUKHODataGridView.Rows[i].Cells[4].Value.ToString())); } ThongKe.xuatfile_HD_NhapHang(cT_NHAP_SP_DK_LUUKHODataGridView, cT_NHAP_SP_DK_LUUKHODataGridView.Rows[0].Cells[0].Value.ToString(), tongtien.ToString(), sol.ToString(), DateTime.Now.ToString("dd/MM/yyyy"), "HoaDon_NhapHang"); //==================================== this.nHAPHANG1TableAdapter.Fill(this.nghiepVu.NHAPHANG1); this.kHO1TableAdapter.Fill(this.nghiepVu.KHO1); //XU LY HOA DON // hOADONTableAdapter.Insert_my("NCC001", "MLHD01 ", Convert.ToDateTime("2000/01/01"), "temp", "NV01"); ////hOADON1TableAdapter.Insert("khong ", cT_NHAP_SP_DK_LUUKHODataGridView.CurrentRow.Cells[2].Value.ToString(), "khong ", "MLHD01 ", DateTime.Today, null,null, tAIKHOANDataGridView.Rows[0].Cells[1].Value.ToString()); MessageBox.Show("Thành Công"); }