示例#1
0
        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");
        }