Esempio n. 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;
                string    fromdate   = "01/01/1900";
                string    todate     = "01/01/1900";
                string    _value     = "1";
                if (optThang.Checked)
                {
                    if (cboThang.SelectedIndex < 0)
                    {
                        Utility.ShowMsg("Bạn phải chọn Tháng báo cáo");
                        cboThang.Focus();
                        return;
                    }
                    _value = cboThang.SelectedValue.ToString();
                    switch (_value)
                    {
                    case "2":
                        fromdate = new DateTime(dtpNam.Value.Year, Utility.Int32Dbnull(_value, 2), 1).ToString("dd/MM/yyyy");
                        todate   = new DateTime(dtpNam.Value.Year, Utility.Int32Dbnull(_value, 2), 29).ToString("dd/MM/yyyy");
                        break;

                    case "4":
                    case "6":
                    case "9":
                    case "11":
                        fromdate = new DateTime(dtpNam.Value.Year, Utility.Int32Dbnull(_value, 2), 1).ToString("dd/MM/yyyy");
                        todate   = new DateTime(dtpNam.Value.Year, Utility.Int32Dbnull(_value, 2), 30).ToString("dd/MM/yyyy");
                        break;

                    default:
                        fromdate = new DateTime(dtpNam.Value.Year, Utility.Int32Dbnull(_value, 2), 1).ToString("dd/MM/yyyy");
                        todate   = new DateTime(dtpNam.Value.Year, Utility.Int32Dbnull(_value, 2), 31).ToString("dd/MM/yyyy");
                        break;
                    }
                }
                else if (optQuy.Checked)
                {
                    if (cboQuy.SelectedIndex < 0)
                    {
                        Utility.ShowMsg("Bạn phải chọn Quý báo cáo");
                        cboQuy.Focus();
                        return;
                    }
                    _value = cboQuy.SelectedValue.ToString();
                    switch (_value)
                    {
                    case "1":
                        fromdate = new DateTime(dtpNam.Value.Year, 1, 1).ToString("dd/MM/yyyy");
                        todate   = new DateTime(dtpNam.Value.Year, 3, 31).ToString("dd/MM/yyyy");
                        break;

                    case "2":
                        fromdate = new DateTime(dtpNam.Value.Year, 4, 1).ToString("dd/MM/yyyy");
                        todate   = new DateTime(dtpNam.Value.Year, 6, 30).ToString("dd/MM/yyyy");
                        break;

                    case "3":
                        fromdate = new DateTime(dtpNam.Value.Year, 7, 1).ToString("dd/MM/yyyy");
                        todate   = new DateTime(dtpNam.Value.Year, 9, 30).ToString("dd/MM/yyyy");
                        break;

                    case "4":
                        fromdate = new DateTime(dtpNam.Value.Year, 10, 1).ToString("dd/MM/yyyy");
                        todate   = new DateTime(dtpNam.Value.Year, 12, 31).ToString("dd/MM/yyyy");
                        break;

                    default:
                        fromdate = new DateTime(dtpNam.Value.Year, 1, 1).ToString("dd/MM/yyyy");
                        todate   = new DateTime(dtpNam.Value.Year, 12, 31).ToString("dd/MM/yyyy");
                        break;
                    }
                }
                else if (optNam.Checked)
                {
                    fromdate = new DateTime(dtpNam.Value.Year, 1, 1).ToString("dd/MM/yyyy");
                    todate   = new DateTime(dtpNam.Value.Year, 12, 31).ToString("dd/MM/yyyy");
                }
                else
                {
                    fromdate = dtFromDate.Value.ToString("dd/MM/yyyy");
                    todate   = dtToDate.Value.ToString("dd/MM/yyyy");
                }
                m_dtReport =
                    BAOCAO_THUOC.ThuocThethuocChitiet(fromdate, todate,
                                                      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, "Thuoc_sochitietvatlieu.xml");
                }

                Utility.SetDataSourceForDataGridEx(grdListChitiet, 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);


                ProcessDataChitiet(ref m_dtReport);
                thuoc_baocao.ThethuocChitiet(m_dtReport, KIEU_THUOC_VT, baocaO_TIEUDE1.TIEUDE,
                                             dtNgayIn.Value, FromDateToDate,
                                             Utility.sDbnull(cboKho.Text));
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
Esempio n. 2
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);
            }
        }