Beispiel #1
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            crpDsKhachHang MyReport = new crpDsKhachHang();

            BindingSource gdSource = new BindingSource();

            gdSource = (BindingSource)this.dataGridView1.DataSource;
            MyReport.SetDataSource(gdSource.DataSource);
            MyReport.SetParameterValue("Nguoi_Sdung", DatLoa.NameReturn("TEN_NHAN_VIEN", "TB_NHAN_VIEN", "MA_NHAN_VIEN = '" + UserInformation.MaNV + "'"));

            frmReportViewer f = new frmReportViewer();

            f.crystalReportViewer1.ReportSource = MyReport;
            f.ShowDialog();
        }
Beispiel #2
0
 private void frmHistory_Load(object sender, EventArgs e)
 {
     btnBack.Enabled = false;
     lstHistory.Clear();
     _Filter = TB_History + _Filter + " order by NGAY_SUA desc";
     loadData();
     if (vCheck == 1)//Có load Next không ?
     {
         btnNext.Enabled = false;
     }
     else
     {
         btnNext.Enabled = true;
     }
     if (!Find)
     {
         dStartDate.Text = DatLoa.NameReturn("min(ngay_sua)", TB_History, "(1=1)");
     }
     lblID1.Text = lstHistory.Columns[0].Text;
     lblID2.Text = lstHistory.Columns[1].Text;
 }
Beispiel #3
0
        private void btnIn_Click(object sender, EventArgs e)
        {
            crpBC_TonKho  MyReport = new crpBC_TonKho();
            BindingSource gdSource = new BindingSource();

            gdSource = (BindingSource)this.dataGridView1.DataSource;
            MyReport.SetDataSource(gdSource.DataSource);
            MyReport.SetParameterValue("Nguoi_Sdung", DatLoa.NameReturn("TEN_NHAN_VIEN", "TB_NHAN_VIEN", "MA_NHAN_VIEN = '" + UserInformation.MaNV + "'"));
            if (DatLoa.NameReturn("TEN_DVI", "TB_DVI", "MA_DVI = '" + txtDvi.Text + "'") == "")
            {
                MyReport.SetParameterValue("Chi_Nhanh", "Tất cả Chi Nhánh");
            }
            else
            {
                MyReport.SetParameterValue("Chi_Nhanh", DatLoa.NameReturn("TEN_DVI", "TB_DVI", "MA_DVI = '" + txtDvi.Text + "'"));
            }

            if (DatLoa.NameReturn("TEN_NHOM_HANG", "TB_NHOM_HANG", "MA_NHOM_HANG = '" + txtNhom.Text + "'") == "")
            {
                MyReport.SetParameterValue("Nhom_Hang", "Tất cả Nhóm Hàng");
            }
            else
            {
                MyReport.SetParameterValue("Nhom_Hang", DatLoa.NameReturn("TEN_NHOM_HANG", "TB_NHOM_HANG", "MA_NHOM_HANG = '" + txtNhom.Text + "'"));
            }

            if (DatLoa.NameReturn("TEN_HANG", "TB_MAT_HANG", "MA_HANG = '" + txtMaHang.Text + "'") == "")
            {
                MyReport.SetParameterValue("Mat_Hang", "Tất cả Mặt Hàng");
            }
            else
            {
                MyReport.SetParameterValue("Mat_Hang", DatLoa.NameReturn("TEN_HANG", "TB_MAT_HANG", "MA_HANG = '" + txtMaHang.Text + "'"));
            }

            MyReport.SetParameterValue("Ngay", String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(dDate.Text)));

            frmReportViewer f = new frmReportViewer();

            f.crystalReportViewer1.ReportSource = MyReport;
            f.ShowDialog();
        }
        public static string vPQ(string code)
        {
            DataLoading DL = new DataLoading();

            return(DL.NameReturn("PQUYEN", "[USER]", "CODE = '" + code + "'"));
        }
        public static string vCheckPass(string code)
        {
            DataLoading DL = new DataLoading();

            return(DL.NameReturn("CHECK_PASS", "[USER]", "CODE = '" + code + "'"));
        }
        public static string vName(string MaNV, string MaDV)
        {
            DataLoading DL = new DataLoading();

            return(DL.NameReturn("TEN_NHAN_VIEN", "TB_NHAN_VIEN", "MA_NHAN_VIEN = '" + MaNV + "' and MA_DVI = '" + MaDV + "'"));
        }
        public static string vMaDV(string Code)
        {
            DataLoading DL = new DataLoading();

            return(DL.NameReturn("MA_DVI", "[USER]", "CODE = '" + Code + "'"));
        }
Beispiel #8
0
        private void ViewMode()
        {
            switch (_pMode)
            {
            case "":
                txtMaKH.Text               = "";
                txtMaMH.Text               = "";
                txtDongiaMH.Enabled        = false; txtDongiaMH.Text = "";
                txtSoluongMH.Enabled       = false; txtSoluongMH.Text = "";
                txtTyleChietKhauMH.Enabled = false; txtTyleChietKhauMH.Text = "0";
                txtTienChietkhauMH.Enabled = false; txtTienChietkhauMH.Text = "0";
                txtTamtinhHD.Text          = "0";
                txtTyleChietKhauHD.Enabled = false;
                txtTienChieuKhauHD.Enabled = false; txtTienChieuKhauHD.Text = "0";
                txtKhachtra.Enabled        = false; txtKhachtra.Text = "";
                txtTongtienHD.Text         = "0"; txtConlai.Text = "";
                txtTongSL.Text             = "0";

                if (LOAI == "X")
                {
                    lblTenPhieu.Text = "Phiếu Bán Hàng";
                }
                else if (LOAI == "N")
                {
                    lblTenPhieu.Text = "Phiếu Nhập Hàng";
                }

                lblNgayLap.Text = DateTime.Now.ToString("dd/MM/yyyy");
                lblTenNV.Text   = DatLoa.NameReturn("TEN_NHAN_VIEN", "TB_NHAN_VIEN", "MA_NHAN_VIEN = '" + UserInformation.MaNV + "'");
                lblDv.Text      = DatLoa.NameReturn("TEN_DVI", "TB_DVI", "MA_DVI = '" + MA_DVI + "'");
                break;

            case "ADD_MH":
                txtMaMH.Text               = "";
                txtDongiaMH.Enabled        = false; txtDongiaMH.Text = "";
                txtSoluongMH.Enabled       = false; txtSoluongMH.Text = "";
                txtTyleChietKhauMH.Enabled = false; txtTyleChietKhauMH.Text = "0";
                txtTienChietkhauMH.Enabled = false; txtTienChietkhauMH.Text = "0";
                break;

            case "EDIT_MH":
                txtMaMH.Text = dataGridView1.CurrentRow.Cells["MA_HANG"].Value.ToString();
                //if (LOAI == "X") txtSoluongMH.Text = dataGridView1.CurrentRow.Cells["SL_XUAT"].Value.ToString();
                //else if (LOAI == "N") txtSoluongMH.Text = dataGridView1.CurrentRow.Cells["SL_NHAP"].Value.ToString();
                //txtDongiaMH.Text = dataGridView1.CurrentRow.Cells["DON_GIA"].Value.ToString();
                //txtTienChietkhauMH.Text = dataGridView1.CurrentRow.Cells["CHIET_KHAU"].Value.ToString();
                break;

            default:
                break;
            }
        }
Beispiel #9
0
        private void btnExcel_Click(object sender, EventArgs e)
        {
            using (frmImExQuestion excQ = new frmImExQuestion())
            {
                DialogResult dlr = excQ.ShowDialog();
                if (dlr == DialogResult.Yes)
                {
                    using (OpenFileDialog ofd = new OpenFileDialog())           //Mở form chọn file (form hệ thống)
                    {
                        ofd.Filter = "Các tệp excel|*.xlsx|Tất cả các tệp|*.*"; //Lọc file .excel
                        if (ofd.ShowDialog() == DialogResult.OK)                //Kiểm tra tệp có được chọn không ?
                        {
                            using (frmExecl exc = new frmExecl())               //Mở form load Excel
                            {
                                exc.datagoc  = dataGridView1;
                                exc.FilePath = ofd.FileName;
                                exc.table    = "TB_MAT_HANG";
                                if (exc.ShowDialog() == DialogResult.OK)
                                {
                                    frmMatHang_Load(sender, e);
                                }
                            }
                        }
                    }
                }
                else if (dlr == DialogResult.No)
                {
                    using (SaveFileDialog sfd = new SaveFileDialog())
                    {
                        sfd.Filter = "Các tệp excel|*.xlsx|Tất cả các tệp|*.*"; //Lọc file .excel
                        if (sfd.ShowDialog() == DialogResult.OK)
                        {
                            Excel.Application app   = new Excel.Application();         //Tạo excel app
                            Excel.Workbook    wb    = app.Workbooks.Add(Type.Missing); //tạo workbook
                            Excel.Worksheet   sheet = null;                            //tạo sheet
                            //Excel.Range Cells;
                            try
                            {
                                //đọc dữ liệu từ dtg ra excel
                                sheet      = wb.ActiveSheet;
                                sheet.Name = "Dữ liệu xuất";
                                #region Sinh Tiêu đề
                                sheet.Range[sheet.Cells[1, 2], sheet.Cells[1, dataGridView1.Columns.Count]].Merge();
                                sheet.Cells[1, 2].Value = "Danh sách Mặt hàng của " + DatLoa.NameReturn("TEN_DVI", "TB_DVI", "MA_DVI='" + UserInformation.MaDV + "'");
                                sheet.Cells[1, 2].HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; //căn giữa
                                sheet.Cells[1, 2].Font.Size           = 20;                            //Cỡ chữ
                                sheet.Cells[1, 2].Borders.Weight      = Excel.XlBorderWeight.xlThin;
                                #endregion

                                #region Sinh cột
                                for (int i = 1; i <= dataGridView1.Columns.Count; i++)
                                {
                                    sheet.Cells[2, i] = dataGridView1.Columns[i - 1].HeaderText;
                                    sheet.Cells[2, i].HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                                    sheet.Cells[2, i].Font.Bold           = true;
                                    sheet.Cells[2, i].Borders.Weight      = Excel.XlBorderWeight.xlThin;
                                }
                                #endregion

                                #region Sinh dữ liệu
                                sheet.Columns[2].NumberFormat = "@";//chuyển về dạng text
                                for (int i = 1; i <= dataGridView1.Rows.Count; i++)
                                {
                                    for (int j = 1; j <= dataGridView1.Columns.Count; j++)
                                    {
                                        sheet.Cells[i + 2, j] = dataGridView1.Rows[i - 1].Cells[j - 1].Value.ToString();
                                        sheet.Cells[i + 2, j].Borders.weight = Excel.XlBorderWeight.xlThin;
                                        if (j == 11)                                                                   // tinh chỉnh cột 10
                                        {
                                            sheet.Cells[i + 2, j].HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; //căn giữa
                                        }
                                    }
                                }
                                sheet.Columns[7].Delete(); sheet.Columns[5].Delete(); sheet.Columns[4].Delete(); sheet.Columns[1].Delete();//Xóa cột không cần
                                #endregion

                                wb.SaveAs(sfd.FileName);
                                MessageBox.Show("Lưu tập tin thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("Lỗi lưu tệp tin\n" + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            finally
                            {
                                app.Quit();
                                //wb = null;
                            }
                        }
                    }
                }
            }
        }
Beispiel #10
0
 private void dataGridView1_CellValidated(object sender, DataGridViewCellEventArgs e)
 {
     dataGridView1.CurrentRow.Cells["TEN_PQ"].Value = DatLoa.NameReturn("TEN_PQ", "TB_PHAN_QUYEN", " MA_PQ='" + dataGridView1.CurrentRow.Cells["PQUYEN"].Value + "'");
 }
Beispiel #11
0
 //Xử lý trên key trên form-----------------------------------------------------------
 private void txtBranchID_TextChanged(object sender, EventArgs e)
 {
     lblNameBranch.Text = DatLoa.NameReturn("TEN_DVI", "TB_DVI", "MA_DVI = '" + txtBranchID.Text + "'");
 }