Beispiel #1
0
        /// <summary>
        /// hàm thực hiện in phiếu báo cáo
        /// thông tin
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdBaoCao_Click(object sender, EventArgs e)
        {
            try
            {
                string nhomthuoc = "-1";
                if (cboKho.SelectedIndex < 0)
                {
                    Utility.ShowMsg("Bạn phải chọn Kho thuốc để xem thẻ thuốc");
                    cboKho.Focus();
                    return;
                }
                if (txtthuoc.MyCode == "-1")
                {
                    Utility.ShowMsg("Bạn phải chọn thuốc để xem thẻ thuốc");
                    txtthuoc.Focus();
                    return;
                }
                nhomthuoc = txtLoaithuoc.MyID.ToString();
                DataTable m_dtReport = null;
                if (chkSimple.Checked)
                {
                    m_dtReport =
                        BAOCAO_THUOC.ThuocThethuoc(chkByDate.Checked ? dtFromDate.Text : Utility.sDbnull("01/01/1900"),
                                                   chkByDate.Checked
                                                       ? dtToDate.Text
                                                       : globalVariables.SysDate.ToString(),
                                                   Utility.Int32Dbnull(cboKho.SelectedValue),
                                                   Utility.Int32Dbnull(txtthuoc.MyID, -1), nhomthuoc,
                                                   chkBiendong.Checked ? 1 : 0);
                }
                else
                {
                    if (chkThekhochitiet.Checked)
                    {
                        if (_item != null && Utility.Byte2Bool(_item.LaTuthuoc))
                        {
                            m_dtReport =
                                BAOCAO_THUOC.ThuocThethuocTutrucChitiet(
                                    chkByDate.Checked ? dtFromDate.Text : Utility.sDbnull("01/01/1900"),
                                    chkByDate.Checked ? dtToDate.Text : globalVariables.SysDate.ToString(),
                                    Utility.Int32Dbnull(cboKho.SelectedValue), Utility.Int32Dbnull(txtthuoc.MyID, -1),
                                    nhomthuoc, chkBiendong.Checked ? 1 : 0);
                        }
                        else
                        {
                            m_dtReport =
                                BAOCAO_THUOC.ThuocThethuocChitiet(
                                    chkByDate.Checked ? dtFromDate.Text : Utility.sDbnull("01/01/1900"),
                                    chkByDate.Checked ? dtToDate.Text : globalVariables.SysDate.ToString(),
                                    Utility.Int32Dbnull(cboKho.SelectedValue), Utility.Int32Dbnull(txtthuoc.MyID, -1),
                                    nhomthuoc, chkBiendong.Checked ? 1 : 0);
                        }
                    }
                    else
                    {
                        if (_item != null && Utility.Byte2Bool(_item.LaTuthuoc))
                        {
                            m_dtReport =
                                BAOCAO_THUOC.ThuocThethuocTutruc(
                                    chkByDate.Checked ? dtFromDate.Text : Utility.sDbnull("01/01/1900"),
                                    chkByDate.Checked ? dtToDate.Text : globalVariables.SysDate.ToString(),
                                    Utility.Int32Dbnull(cboKho.SelectedValue), Utility.Int32Dbnull(txtthuoc.MyID, -1),
                                    nhomthuoc, chkBiendong.Checked ? 1 : 0);
                        }
                        else

                        {
                            if (_item.KieuKho == "CHAN" || (chkChanle.Enabled && chkChanle.Checked))
                            {
                                m_dtReport =
                                    BAOCAO_THUOC.ThuocThethuocKhochan(
                                        chkByDate.Checked ? dtFromDate.Text : Utility.sDbnull("01/01/1900"),
                                        chkByDate.Checked ? dtToDate.Text : globalVariables.SysDate.ToString(),
                                        Utility.Int32Dbnull(cboKho.SelectedValue),
                                        Utility.Int32Dbnull(txtthuoc.MyID, -1), nhomthuoc, chkBiendong.Checked ? 1 : 0);
                            }
                            else
                            {
                                m_dtReport =
                                    BAOCAO_THUOC.ThuocThethuocKhole(
                                        chkByDate.Checked ? dtFromDate.Text : Utility.sDbnull("01/01/1900"),
                                        chkByDate.Checked ? dtToDate.Text : globalVariables.SysDate.ToString(),
                                        Utility.Int32Dbnull(cboKho.SelectedValue),
                                        Utility.Int32Dbnull(txtthuoc.MyID, -1), nhomthuoc, chkBiendong.Checked ? 1 : 0);
                            }
                        }
                    }
                }
                if (_item != null && Utility.Byte2Bool(_item.LaTuthuoc))
                {
                    THU_VIEN_CHUNG.CreateXML(m_dtReport,
                                             chkThekhochitiet.Checked
                                                 ? "ThuocThethuocTutrucChitiet.xml"
                                                 : "ThuocThethuocTutruc.xml");
                }
                else
                {
                    THU_VIEN_CHUNG.CreateXML(m_dtReport,
                                             chkThekhochitiet.Checked
                                                 ? "thethuoc_chitiet.xml"
                                                 : (_item.KieuKho == "CHAN" || (chkChanle.Enabled && chkChanle.Checked)
                                                        ? "Thethuoc_khochan.xml"
                                                        : "Thethuoc_khole.xml"));
                }
                Utility.SetDataSourceForDataGridEx(
                    chkSimple.Checked
                        ? grdThethuoc
                        : (
                        chkThekhochitiet.Checked
                                  ? grdListChitiet
                                  : (
                            _item != null && Utility.Byte2Bool(_item.LaTuthuoc)
                                            ? grdThethuoctutruc
                                            : (_item.KieuKho == "CHAN" || (chkChanle.Enabled && chkChanle.Checked)
                                                   ? grdListKhoChan
                                                   : grdListKhole)
                            )
                        )
                    , m_dtReport, true, true, "1=1", "");
                if (m_dtReport == null || m_dtReport.Rows.Count <= 0)
                {
                    Utility.ShowMsg("Không tìm thấy dữ liệu báo cáo", "Thông báo", MessageBoxIcon.Warning);
                    return;
                }
                string FromDateToDate = Utility.FromToDateTime(dtFromDate.Text, dtToDate.Text);
                if (chkSimple.Checked)
                {
                    ProcessDataThethuoc(ref m_dtReport);
                    thuoc_baocao.Thethuoc(m_dtReport, KIEU_THUOC_VT, baocaO_TIEUDE1.TIEUDE,
                                          dtNgayIn.Value, FromDateToDate,
                                          Utility.sDbnull(cboKho.Text));
                }
                else
                {
                    if (chkThekhochitiet.Checked)
                    {
                        ProcessDataChitiet(ref m_dtReport);
                        thuoc_baocao.ThethuocChitiet(m_dtReport, KIEU_THUOC_VT, baocaO_TIEUDE1.TIEUDE,
                                                     dtNgayIn.Value, FromDateToDate,
                                                     Utility.sDbnull(cboKho.Text));
                    }
                    else
                    {
                        if (_item != null && Utility.Byte2Bool(_item.LaTuthuoc))
                        {
                            ProcessDataTutruc(ref m_dtReport);
                            thuoc_baocao.Thethuoctutruc(m_dtReport, KIEU_THUOC_VT, baocaO_TIEUDE1.TIEUDE,
                                                        dtNgayIn.Value, FromDateToDate,
                                                        Utility.sDbnull(cboKho.Text));
                        }
                        else
                        {
                            if (_item.KieuKho == "CHAN" || (chkChanle.Enabled && chkChanle.Checked))
                            {
                                ProcessDataKhochan(ref m_dtReport);
                                thuoc_baocao.Thethuockhochan(m_dtReport, KIEU_THUOC_VT, baocaO_TIEUDE1.TIEUDE,
                                                             dtNgayIn.Value, FromDateToDate,
                                                             Utility.sDbnull(cboKho.Text));
                            }
                            else
                            {
                                ProcessDataKhole(ref m_dtReport);
                                thuoc_baocao.ThethuocKhole(m_dtReport, KIEU_THUOC_VT, baocaO_TIEUDE1.TIEUDE,
                                                           dtNgayIn.Value, FromDateToDate,
                                                           Utility.sDbnull(cboKho.Text));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }