Exemple #1
0
 private void sothe_Validated(object sender, System.EventArgs e)
 {
     if (sothe.Value == 0)
     {
         mien.Focus();
     }
 }
Exemple #2
0
 private void ra3_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         m_chkEmergency.Focus();
     }
 }
Exemple #3
0
 private void cmbphong_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         chk.Focus();
     }
 }
Exemple #4
0
 private void txtNam_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
 {
     try
     {
         if (e.KeyCode == Keys.Enter)
         {
             chkCosolieu.Focus();
         }
     }
     catch
     {
     }
 }
Exemple #5
0
        private void butOk_Click(object sender, System.EventArgs e)
        {
            if (!chkbieu112.Checked && !chkbieu111.Checked)
            {
                MessageBox.Show(lan.Change_language_MessageText("Chọn cách kết xuất số liệu !"), LibMedi.AccessData.Msg);
                chkbieu111.Focus();
                return;
            }
            if (!chkbieu022.Checked && !chkbieu021.Checked)
            {
                MessageBox.Show(lan.Change_language_MessageText("Chọn cách kết xuất số liệu !"), LibMedi.AccessData.Msg);
                chkbieu021.Focus();
                return;
            }
            if (!chkbieu0312.Checked && !chkbieu0311.Checked)
            {
                MessageBox.Show(lan.Change_language_MessageText("Chọn cách kết xuất số liệu !"), LibMedi.AccessData.Msg);
                chkbieu0311.Focus();
                return;
            }
            if (!chkbieu042.Checked && !chkbieu041.Checked)
            {
                MessageBox.Show(lan.Change_language_MessageText("Chọn cách kết xuất số liệu !"), LibMedi.AccessData.Msg);
                chkbieu041.Focus();
                return;
            }
            try
            {
                m.upd_thongso(8, "ten", ketxuat.Text.ToString().Trim());
                s_tu  = "01/01/" + nam.Value.ToString();
                s_tu2 = "01/10/" + nam.Value.ToString();
                s_den = "31/12/" + nam.Value.ToString();
                switch (ky.SelectedIndex)
                {
                case 0:
                    s_tu2 = "01/01/" + nam.Value.ToString();
                    s_den = "31/03/" + nam.Value.ToString();
                    break;

                case 1:
                    s_tu2 = "01/04/" + nam.Value.ToString();
                    s_den = "30/06/" + nam.Value.ToString();
                    break;

                case 2:
                    s_tu2 = "01/07/" + nam.Value.ToString();
                    s_den = "30/09/" + nam.Value.ToString();
                    break;
                }
                s_tu1 = s_tu;
                if (m.bCongdon)
                {
                    s_tu = s_tu2;
                }
                j = ky.SelectedIndex + 1;
                string dir      = System.IO.Directory.GetCurrentDirectory() + "\\temp";
                string exp      = dir + "//" + ky.Text.Substring(0, 2) + nam.Value.ToString();
                string sql      = "";
                string filexuat = dir + "//" + m.Mabv_so.ToString() + j.ToString() + nam.Value.ToString() + ".ZIP";
                string filecopy = ketxuat.Text + "//" + m.Mabv_so.ToString() + j.ToString() + nam.Value.ToString() + ".ZIP";
                if (!Directory.Exists(ketxuat.Text))
                {
                    Directory.CreateDirectory(ketxuat.Text);
                }
                if (!Directory.Exists(exp))
                {
                    Directory.CreateDirectory(exp);
                }
                foreach (DataRow r in m.get_data("select * from " + user + ".dmnop").Tables[0].Rows)
                {
                    tenfile  = m.Mabv_so.ToString() + j.ToString() + nam.Value.ToString() + r["tenfile"].ToString();
                    lbl.Text = tenfile + ".XML";
                    lbl.Refresh();
                    if (r["tenfile"].ToString() == "B1")
                    {
                        sql  = "select id from " + user + ".bieu_01 where ngay between to_date('" + s_tu + "'," + stime + ") and to_date('" + s_den + "'," + stime + ")";
                        ds1  = m.get_data(sql);
                        l_id = (ds1.Tables[0].Rows.Count != 0)?decimal.Parse(ds1.Tables[0].Rows[0][0].ToString()):0;
                        sql  = "select b.matk as ma,sum(a.c01) as c01,sum(a.c02) as c02,sum(a.c03) as c03,sum(a.c04) as c04,sum(a.c05) as c05,sum(a.c06) as c06,sum(a.c07) as c07,sum(a.c08) as c08,sum(a.c09) as c09,sum(a.c10) as c10,sum(a.c11) as c11,sum(a.c12) as c12,sum(a.c13) as c13,sum(a.c14) as c14,sum(a.c15) as c15,sum(a.c16) as c16,sum(a.c17) as c17,";
                        sql += "sum(a.c18) as c18,sum(a.c19) as c19,sum(a.c20) as c20,sum(a.c21) as c21,sum(a.c22) as c22,sum(a.c23) as c23 from " + user + ".bieu_01 a," + user + ".dm_01 b where a.ma=b.ma and a.id=" + l_id + " group by b.matk";
                    }
                    else if (r["tenfile"].ToString() == "KH_B1")
                    {
                        sql  = "select id from " + user + ".kh_bieu_01 where ngay between to_date('" + s_tu + "'," + stime + ") and to_date('" + s_den + "'," + stime + ")";
                        ds1  = m.get_data(sql);
                        l_id = (ds1.Tables[0].Rows.Count != 0)?decimal.Parse(ds1.Tables[0].Rows[0][0].ToString()):0;
                        sql  = "select ma,c01,c02,c03,c04,c05,c06,c07,c08,c09,c10,c11 from " + user + ".kh_bieu_01 where id=" + l_id;
                    }
                    else if (r["tenfile"].ToString() == "KH_B6")
                    {
                        sql  = "select id from " + user + ".kh_bieu_06 where ngay between to_date('" + s_tu + "'," + stime + ") and to_date('" + s_den + "'," + stime + ")";
                        ds1  = m.get_data(sql);
                        l_id = (ds1.Tables[0].Rows.Count != 0)?decimal.Parse(ds1.Tables[0].Rows[0][0].ToString()):0;
                        sql  = "select ma,c01,c02,c03,c04,c05,c06,c07,c08,c09,c10,c11,c12,c13,c14,c15,c16,c17,c18,c19,c20,c21,c22,c23,c24,c25,c26,c27,c28,c29,c30,c31 from " + user + ".kh_bieu_06 where id=" + l_id;
                    }
                    else if (r["tenfile"].ToString() == "KH_B4")
                    {
                        sql  = "SELECT MA,SUM(C01) AS C01,SUM(C02) AS C02,SUM(C03) AS C03,SUM(C04) AS C04,SUM(C05) AS C05,SUM(C06) AS C06,SUM(C07) AS C07,SUM(C08) AS C08,SUM(C09) AS C09,SUM(C10) AS C10,SUM(C11) AS C11,SUM(C12) AS C12,SUM(C13) AS C13,SUM(C14) AS C14,SUM(C15) AS C15,SUM(C16) AS C16,SUM(C17) AS C17 FROM " + user + ".KH_BIEU_04";
                        sql += " where ngay between to_date('" + s_tu + "'," + stime + ") and to_date('" + s_den + "'," + stime + ")";
                        sql += " group by ma";
                    }
                    else
                    {
                        sql = r["sql"].ToString().Trim().Replace("medibv", user) + " where ngay between to_date('" + s_tu + "'," + stime + ") and to_date('" + s_den + "'," + stime + ")";
                        if (r["tenfile"].ToString().Trim() == "B92")
                        {
                            sql += " group by ma,ten";
                        }
                        else
                        {
                            sql += " group by ma";
                        }
                    }
                    if (r["tenfile"].ToString().Substring(0, 2) == "KH")
                    {
                        tenfile = m.Matuyen(m.Mabv) + m.Maqu.Substring(3, 2) + tenfile;
                    }
                    ds = m.get_data(sql);
                    if (r["tenfile"].ToString() == "B7" && ds.Tables[0].Rows.Count != 0)
                    {
                        sql  = "select id from " + user + ".bieu_07 where ngay between to_date('" + s_tu + "'," + stime + ") and to_date('" + s_den + "'," + stime + ")";
                        ds1  = m.get_data(sql);
                        l_id = (ds1.Tables[0].Rows.Count != 0)?decimal.Parse(ds1.Tables[0].Rows[0][0].ToString()):0;
                        DataRow r1;
                        sql = "select ma,soluong from " + user + ".bieu_07 where ma in (21,22,23,24) and id=" + l_id;
                        foreach (DataRow r2 in m.get_data(sql).Tables[0].Rows)
                        {
                            r1 = m.getrowbyid(ds.Tables[0], "ma=" + int.Parse(r2["ma"].ToString()));
                            if (r1 != null)
                            {
                                r1["soluong"] = r2["soluong"].ToString();
                            }
                        }
                    }
                    if (ds.Tables[0].Rows.Count != 0)
                    {
                        ds.WriteXml(exp + "//" + tenfile + ".XML", XmlWriteMode.WriteSchema);
                    }
                }
                tenfile  = m.Mabv_so.ToString() + j.ToString() + nam.Value.ToString() + "B2";
                lbl.Text = tenfile + ".XML";
                lbl.Refresh();
                ds = export.bieu_02(s_tu, s_tu1, s_den, "dm_02", chkbieu022.Checked, chkbieu021.Checked, true);
                ds.Tables[0].Columns.Remove("stt");
                ds.Tables[0].Columns.Remove("ten");
                ds.WriteXml(exp + "//" + tenfile + ".XML", XmlWriteMode.WriteSchema);

                tenfile  = m.Mabv_so.ToString() + j.ToString() + nam.Value.ToString() + "B31";
                lbl.Text = tenfile + ".XML";
                lbl.Refresh();
                ds = export.bieu_031(s_tu, s_tu1, s_den, "dm_031", chkbieu0312.Checked, chkbieu0311.Checked, true);
                ds.Tables[0].Columns.Remove("stt");
                ds.Tables[0].Columns.Remove("ten");
                ds.WriteXml(exp + "//" + tenfile + ".XML", XmlWriteMode.WriteSchema);

                tenfile  = m.Mabv_so.ToString() + j.ToString() + nam.Value.ToString() + "B4";
                lbl.Text = tenfile + ".XML";
                lbl.Refresh();
                ds = export.bieu_04(s_tu, s_tu1, s_den, "dm_04", chkbieu042.Checked, chkbieu041.Checked, true);
                ds.Tables[0].Columns.Remove("stt");
                ds.Tables[0].Columns.Remove("ten");
                ds.WriteXml(exp + "//" + tenfile + ".XML", XmlWriteMode.WriteSchema);

                tenfile  = m.Mabv_so.ToString() + j.ToString() + nam.Value.ToString() + "B11";
                lbl.Text = tenfile + ".XML";
                lbl.Refresh();
                ds = export.bieu_11(s_tu, s_tu1, s_den, "dm_11", chkbieu112.Checked, chkbieu111.Checked, true);
                ds.Tables[0].Columns.Remove("stt");
                ds.Tables[0].Columns.Remove("ten");
                ds.Tables[0].Columns.Remove("icd10");
                ds.WriteXml(exp + "//" + tenfile + ".XML", XmlWriteMode.WriteSchema);

                tenfile  = m.Mabv_so.ToString() + j.ToString() + nam.Value.ToString() + "KH_B1451";
                tenfile  = m.Matuyen(m.Mabv) + m.Maqu.Substring(3, 2) + tenfile;
                lbl.Text = tenfile + ".XML";
                lbl.Refresh();
                ds = export.kh_bieu_145(s_tu, s_tu1, s_den, "kh_dm_1451", true, true, true);
                ds.Tables[0].Columns.Remove("stt");
                ds.Tables[0].Columns.Remove("ten");
                ds.WriteXml(exp + "//" + tenfile + ".XML", XmlWriteMode.WriteSchema);

                tenfile  = m.Mabv_so.ToString() + j.ToString() + nam.Value.ToString() + "KH_B15";
                tenfile  = m.Matuyen(m.Mabv) + m.Maqu.Substring(3, 2) + tenfile;
                lbl.Text = tenfile + ".XML";
                lbl.Refresh();
                ds = export.kh_bieu_15(s_tu, s_tu1, s_den, "dm_11", chkbieu112.Checked, chkbieu111.Checked, true);
                ds.Tables[0].Columns.Remove("stt");
                ds.Tables[0].Columns.Remove("ten");
                ds.Tables[0].Columns.Remove("icd10");
                ds.WriteXml(exp + "//" + tenfile + ".XML", XmlWriteMode.WriteSchema);

                tenfile  = m.Mabv_so.ToString() + j.ToString() + nam.Value.ToString() + "DMCOSO";
                tenfile  = m.Matuyen(m.Mabv) + m.Maqu.Substring(3, 2) + tenfile;
                lbl.Text = tenfile + ".XML";
                lbl.Refresh();
                m.get_data("select * from " + user + ".dmcoso").WriteXml(exp + "//" + tenfile + ".XML", XmlWriteMode.WriteSchema);

                tenfile  = m.Mabv_so.ToString() + j.ToString() + nam.Value.ToString() + "DMCSSXKD";
                tenfile  = m.Matuyen(m.Mabv) + m.Maqu.Substring(3, 2) + tenfile;
                lbl.Text = tenfile + ".XML";
                lbl.Refresh();
                m.get_data("select * from " + user + ".dmcssxkd").WriteXml(exp + "//" + tenfile + ".XML", XmlWriteMode.WriteSchema);

                //exp_hosobenhan();

                zip.AddFiles(filexuat, exp);
                File.Copy(filexuat, filecopy, true);
                File.Delete(filexuat);
                checkedListBox1.Items.Clear();
                string [] files = Directory.GetFiles(ketxuat.Text);              //exp
                for (int i = 0; i < files.GetLength(0); i++)
                {
                    checkedListBox1.Items.Add(files[i].ToString());
                    if (files[i].ToString().ToUpper().IndexOf(".ZIP") != -1)
                    {
                        checkedListBox1.SetItemCheckState(i, CheckState.Checked);
                    }
                }
                zip.DeleteDirectory(exp);
                //Directory.Delete(exp);
                //Directory.Delete(dir);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #6
0
 //Check check box
 public bool isChecked(CheckBox chckBox)
 {
     if (chckBox.Checked == false)
     {
         MessageBox.Show("Please click the check box to confirm that the email subject and body are correct.", "Confirm Email Subject and Body");
         chckBox.Focus();
         return false;
     }
     else
     {
         return true;
     }
 }