Exemple #1
0
 private void butRef_Click(object sender, System.EventArgs e)
 {
     d.execute_data("delete from " + user + s_mmyy + ".d_tonkhoct where tondau=0 and slnhap=0 and slxuat=0");
     d.execute_data("delete from " + user + s_mmyy + ".d_tonkhoth where tondau=0 and slnhap=0 and slxuat=0");
     d.upd_tonkho(s_mmyy, i_nhom, 1);
     load_grid();
 }
Exemple #2
0
        private void butHuy_Click(object sender, System.EventArgs e)
        {
            if (ds.Tables[0].Rows.Count == 0)
            {
                return;
            }
            string s_ngay = m.ngayhienhanh_server.Substring(0, 10);
            string asql   = "select mabn, maql from xxx.benhanpk where mabn='" + mabn.Text + "' and mavaovien='" + d_mavaovien;

            asql += " UNION ALL ";
            asql += "select mabn, maql from xxx.benhancc where mabn='" + mabn.Text + "' and mavaovien='" + d_mavaovien;
            DataSet ads = m.get_data_mmyy(asql, s_ngay, s_ngay, true);

            if (ads != null && ads.Tables.Count > 0 && ads.Tables[0].Rows.Count > 0)
            {
                MessageBox.Show(lan.Change_language_MessageText("Bệnh nhân này đã khám, không hủy được."));
                return;
            }
            asql = "select mabn, maql from medibv.benhandt where mabn='" + mabn.Text + "' and mavaovien='" + d_mavaovien;
            ads  = m.get_data(asql);
            if (ads != null && ads.Tables.Count > 0 && ads.Tables[0].Rows.Count > 0)
            {
                MessageBox.Show(lan.Change_language_MessageText("Bệnh nhân này đã khám, không hủy được."));
                return;
            }
            if (MessageBox.Show(lan.Change_language_MessageText("Đồng ý hủy ?"), LibMedi.AccessData.Msg, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                d.execute_data("delete from " + user + ".qn_benhnhan where mabn='" + mabn.Text + "' and mavaovien=" + d_mavaovien);
            }
            load_grid();
            ena_object(false);
            butMoi.Focus();
        }
Exemple #3
0
        private void butLuu_Click(object sender, System.EventArgs e)
        {
            if (!kiemtra())
            {
                return;
            }
            if (l_id == 0)
            {
                l_id = decimal.Parse(d.i_Chinhanh_hientai.ToString() + d.get_id_donthuoc_bacsy().ToString());
            }
            else
            {
                d.execute_data("delete from " + user + ".d_theodonct where id=" + l_id);
            }
            d.upd_theodonll(l_id, "", "", mabs.Text, -1, dt.Rows.Count, 1);
            dt.AcceptChanges();
            foreach (DataRow r in dt.Rows)
            {
                DataRow r_dt = m.getrowbyid(dtdoituong, "doituong='" + r["doituong"] + "'");
                r["madoituong"] = r_dt["madoituong"].ToString();
                d.upd_theodonct(l_id, int.Parse(r["mabd"].ToString()), decimal.Parse(r["soluong"].ToString()), r["cachdung"].ToString(), int.Parse(r["stt"].ToString()), int.Parse(r["madoituong"].ToString()));
            }
            ena_object(false);
            decimal id = l_id;

            load_head();
            lmabs.SelectedValue = id;
            l_id = id;
            load_chitiet();
        }
Exemple #4
0
        private void butLuu_Click(object sender, System.EventArgs e)
        {
            if (!kiemtra())
            {
                return;
            }
            l_id = d.get_id_donthuoc_bacsy(mabs.Text, ma.Text);
            if (l_id == 0)
            {
                l_id = d.get_id_donthuoc_bacsy();
            }
            else
            {
                d.execute_data("delete from " + user + ".d_theodonct where id=" + l_id);
            }
            d.upd_theodonll(l_id, mabs.Text, ma.Text, ghichu.Text, 0, dt.Rows.Count, 1);
            foreach (DataRow r in dt.Rows)
            {
                d.upd_theodonct(l_id, int.Parse(r["mabd"].ToString()), decimal.Parse(r["soluong"].ToString()), r["cachdung"].ToString(), int.Parse(r["stt"].ToString()), 0);
            }
            ena_object(false);
            decimal id    = l_id;
            string  _mabs = mabs.Text;

            load_head();
            lmabs.SelectedValue = _mabs;
            load_maicd();
            lmaicd.SelectedValue = id.ToString();
            l_id = id;
            load_chitiet();
        }
Exemple #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (thumuc.Text == "")
            {
                button1_Click(null, null);
                return;
            }
            if (!System.IO.File.Exists(thumuc.Text))
            {
                MessageBox.Show("Không tìm thấy File !");
                return;
            }
            string sql = "";

            sql = " create table " + s_user + ".d_group (id numeric(7), generic1 varchar(255),generic2 varchar(255), group1 varchar(255), group2 varchar(255), severity numeric(3), mechanism text,actions text, s_effect text, mec_detail text)";
            d.execute_data(sql);
            //
            dthc = d.get_data("select * from " + s_user + ".d_group ").Tables[0];
            sql  = "select * from group1 order by generic1";
            string s_name = "", s_generic = "", s_group = "", s_exp = "", s_id = "0", s_severity = "0";
            string s_ploai = "";
            int    i_loai = 0, i_stt = 0, i_id = 0, i_nhom = 1;//Khoa duoc
            long   l_id = 0;

            ds = m.get_data_acc(sql, thumuc.Text);
            int jjj = 0;

            foreach (DataRow r in ds.Tables[0].Rows)
            {
                s_exp = "generic1='" + r["generic1"].ToString().Trim().Replace("'", "") + "' and generic2='" + r["generic2"].ToString().Trim().Replace("'", "") + "'";
                DataRow dr = d.getrowbyid(dthc, s_exp);
                if (dr == null)
                {
                    s_group    = r["group1"].ToString().Trim().Replace("'", "");
                    s_generic  = r["generic1"].ToString().Trim().Replace("'", "");
                    s_id       = (r["id"].ToString().Trim() == "") ? "0" : r["id"].ToString().Trim();
                    s_severity = (r["severity"].ToString().Trim() == "") ? "0" : r["severity"].ToString().Trim();
                    sql        = "insert into " + s_user + ".d_group (id, generic1, generic2, group1, group2, severity, mechanism, actions, s_effect, mec_detail) ";
                    sql       += " values(" + s_id + ",'" + s_generic + "','" + r["generic2"].ToString().Trim().Replace("'", "") + "','" + s_group + "','" + r["group2"].ToString().Trim().Replace("'", "") + "'," + s_severity + ",'" + r["mechanism"].ToString().Trim().Replace("'", "") + "','" + r["actions"].ToString().Trim().Replace("'", "") + "','" + r["s_effect"].ToString().Trim().Replace("'", "") + "','" + r["mec_detail"].ToString().Trim().Replace("'", "") + "')";
                    d.execute_data(sql);
                }
                jjj        += 1;
                label1.Text = "Record " + jjj.ToString();
                this.Refresh();
            }
            thumuc.Text = "";
        }
Exemple #6
0
 private void butHuy_Click(object sender, System.EventArgs e)
 {
     if (ds.Tables[0].Rows.Count == 0)
     {
         return;
     }
     if (MessageBox.Show(lan.Change_language_MessageText("Đồng ý hủy ?"), LibMedi.AccessData.Msg, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         d.execute_data("delete from " + user + ".diungthuoc where mabn='" + mabn.Text + "'" + " and mahc='" + ma.Text + "'");
         m.delrec(ds.Tables[0], "mahc='" + ma.Text + "'");
         ref_text();
     }
 }
Exemple #7
0
        private void f_Chuyen_dmbd(int d_nhomkho_nguon, int d_nhomkho_dich)
        {
            int     m_id     = f_get_maxid("d_dmbd");
            string  s_userdb = d.user;
            string  asql     = "select id from " + s_userdb + ".d_dmbd where nhom=" + d_nhomkho_dich;
            DataSet ads      = d.get_data(asql);

            if (ads != null && ads.Tables.Count > 0 && ads.Tables[0].Rows.Count > 0)
            {
                MessageBox.Show("Danh mục d_dmbd đã chuyển.");
                return;
            }
            string s_field = d.f_get_select_field("d_dmbd", "", "a");

            s_field = s_field.Replace("a.id,", "a.id+" + m_id + " as id,");
            s_field = s_field.Replace("a.nhom,", d_nhomkho_dich + " as nhom,");
            asql    = " insert into " + s_userdb + ".d_dmbd ";
            asql   += "select " + s_field + " from " + s_userdb + ".d_dmbd a where nhom=" + d_nhomkho_nguon;
            d.execute_data(asql);

            asql = "update " + s_userdb + ".d_dmbd set ma=null where nhom=" + d_nhomkho_dich;
            d.execute_data(asql);
            asql = "select id, ma, ten from " + s_userdb + ".d_dmbd where nhom=" + d_nhomkho_dich;
            ads  = d.get_data(asql);
            string s_ma = "";

            foreach (DataRow dr in ads.Tables[0].Rows)
            {
                s_ma = d.getMabd("d_dmbd", dr["ten"].ToString(), d_nhomkho_dich);
                if (s_ma != "")
                {
                    asql = "update " + s_userdb + ".d_dmbd set ma='" + s_ma + "' where id=" + dr["id"].ToString();
                    d.execute_data(asql);
                }
                lblStatus.Text = dr["ten"].ToString();
                lblStatus.Refresh();
            }
        }
Exemple #8
0
        private void butOk_Click(object sender, System.EventArgs e)
        {
            string mmyy = mm.Value.ToString().PadLeft(2, '0') + yyyy.Value.ToString().Substring(2, 2);

            if (!d.bMmyy(mmyy))
            {
                MessageBox.Show(lan.Change_language_MessageText("Số liệu tháng") + " " + mmyy.Substring(0, 2) + " " + lan.Change_language_MessageText("năm") + " " + mmyy.Substring(2, 2) + " " + lan.Change_language_MessageText("chưa tạo !"), d.Msg);
                mm.Focus();
                return;
            }
            if (d.bKhoaso(i_nhom, mmyy))
            {
                MessageBox.Show(lan.Change_language_MessageText("Số liệu tháng") + " " + mmyy.Substring(0, 2) + " " + lan.Change_language_MessageText("năm") + " " + mmyy.Substring(2, 2) + " " + lan.Change_language_MessageText("đã khóa !") + "\n" + lan.Change_language_MessageText("Nếu cần thay đổi thì vào mục khai báo hệ thống"), d.Msg);
                return;
            }
            if (MessageBox.Show(lan.Change_language_MessageText("Bạn có đồng ý cập nhật !"), d.Msg, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                Cursor = Cursors.WaitCursor;
                string sql = "update " + d.user + mmyy + ".d_tonkhoth set slyeucau=0 where makho in (select id from " + d.user + ".d_dmkho where nhom=" + i_nhom + ")";
                d.execute_data(sql);
                Cursor = Cursors.Default;
                MessageBox.Show(lan.Change_language_MessageText("Đã cập nhật số lượng tồn treo !"), d.Msg);
            }
        }
Exemple #9
0
 private void butRef_Click(object sender, System.EventArgs e)
 {
     d.execute_data("delete from " + xxx + ".d_tutrucct where tondau=0 and slnhap=0 and slxuat=0");
     d.execute_data("delete from " + xxx + ".d_tutructh where tondau=0 and slnhap=0 and slxuat=0");
     load_grid();
 }
Exemple #10
0
        private void butOk_Click(object sender, System.EventArgs e)
        {
            bOk = true;
            bool bChieu_sang = m.bChieu_sang;

            if (bChieu_sang)
            {
                DataRow r1, r2;
                r2 = d.getrowbyid(dtphieu, "id=" + int.Parse(phieu.SelectedValue.ToString()));
                if (r2 != null)
                {
                    if (r2["buoi"].ToString() == "0")
                    {
                        r1 = d.getrowbyid(dtkp, "id=" + int.Parse(makp.SelectedValue.ToString()));
                        if (r1 != null)
                        {
                            if (d.get_ttngay(s_ngay, r1["makp"].ToString()))
                            {
                                MessageBox.Show(lan.Change_language_MessageText("Ngày") + " " + s_ngay + " " + lan.Change_language_MessageText("viện phí đã in danh sách thu tiền") + "\n" + lan.Change_language_MessageText("Yêu cầu chọn phiếu buổi chiều !"), d.Msg);
                                return;
                            }
                        }
                    }
                }
            }
            if (makp.SelectedIndex == -1 || phieu.SelectedIndex == -1)
            {
                if (makp.SelectedIndex == -1)
                {
                    makp.Focus();
                }
                else
                {
                    phieu.Focus();
                }
                return;
            }
            i_makp  = int.Parse(makp.SelectedValue.ToString());
            i_phieu = int.Parse(phieu.SelectedValue.ToString());
            DataTable tmp = d.get_data("select * from " + xxx + ".d_daduyet where nhom=" + i_nhom + " and to_char(ngay,'dd/mm/yyyy')='" + s_ngay + "' and makp=" + i_makp + " and loai=" + i_loai + " and phieu=" + i_phieu + " and makp=" + i_makp).Tables[0];

            if (tmp.Select("done=1").Length > 0)
            {
                MessageBox.Show(lan.Change_language_MessageText("Phiếu này đã đánh dấu phát") + "\n" + lan.Change_language_MessageText("Không cho phép hủy ?"), d.Msg);
                makp.Focus();
                return;
            }
            try
            {
                bDuyettreole = tmp.Select("duyettreole=1").Length > 0;
            }
            catch { bDuyettreole = false; }
            string tenfile = (i_loai == 2 || bBuhaophi)?"d_bucstt":"d_xuatsdct";

            sql = "select distinct a.mabn,a.maql";
            if (!bIntheocstt)
            {
                sql += ",a.makhoa";
            }
            sql += ",b.mabd";
            sql += " from " + xxx + ".d_xuatsdll a," + xxx + "." + tenfile + " b where a.id=b.id and to_char(a.ngay,'dd/mm/yyyy')='" + s_ngay + "'";
            sql += " and a.nhom=" + i_nhom + " and a.loai=" + i_loai + " and a.phieu=" + i_phieu;
            if (i_loai == 2)
            {
                if (bIntheocstt)
                {
                    sql += " and a.makp=" + i_makp;
                }
                else
                {
                    sql += " and a.makhoa=" + i_makp;
                }
            }
            else
            {
                sql += " and a.makhoa=" + i_makp;
            }
            sql += " and a.thuoc=" + i_thuoc;
            if (bBuhaophi || i_loai == 4 || bThua || i_thuoc == 2)
            {
                sql += " and a.maql=0";
            }
            else
            {
                sql += " and a.maql<>0";
            }
            tmp = d.get_data(sql).Tables[0];
            if (tmp.Rows.Count == 0)
            {
                if (kiemtra())
                {
                    MessageBox.Show(lan.Change_language_MessageText("Đã thu hồi xong."), lan.Change_language_MessageText("Thu hồi"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    d.close(); this.Close();
                    return;
                }
                MessageBox.Show(lan.Change_language_MessageText("Không có số liệu !"), d.Msg);
                f_thuhoi_phieu_biloi(s_mmyy, s_ngay, i_makp, i_nhom, i_phieu);
                makp.Focus();
                return;
            }
            string s_makhoa = "";

            if (!bIntheocstt)
            {
                foreach (DataRow r in tmp.Select("true", "makhoa"))
                {
                    if (s_makhoa.IndexOf(r["makhoa"].ToString().Trim() + ",") == -1)
                    {
                        s_makhoa += r["makhoa"].ToString().Trim() + ",";
                    }
                }
            }

            bool bFound = false;

            if (i_loai == 1 || i_loai == 3)
            {
                string s_id = "";
                sql  = "select distinct a.id";
                sql += " from " + xxx + ".d_xuatsdll a," + xxx + "." + tenfile + " b where a.id=b.id and to_char(a.ngay,'dd/mm/yyyy')='" + s_ngay + "'";
                sql += " and a.nhom=" + i_nhom + " and a.loai=" + i_loai + " and a.phieu=" + i_phieu;
                sql += " and a.makhoa=" + i_makp;
                sql += " and a.thuoc=" + i_thuoc;
                sql += " and a.maql<>0";
                foreach (DataRow r in d.get_data(sql).Tables[0].Rows)
                {
                    s_id += r["id"].ToString().Trim() + ",";
                }
                if (s_id != "")
                {
                    string _mabn = "";
                    foreach (DataRow r in d.get_data("select a.mabn,b.hoten from " + xxx + ".d_tienthuoc a," + user + ".btdbn b where a.mabn=b.mabn and a.id in (" + s_id.Substring(0, s_id.Length - 1) + ") and a.done=1 order by a.mabn").Tables[0].Rows)
                    {
                        if (_mabn.IndexOf(r["mabn"].ToString() + " " + r["hoten"].ToString().Trim()) == -1)
                        {
                            _mabn += r["mabn"].ToString() + " " + r["hoten"].ToString().Trim() + "\n";
                        }
                    }
                    if (_mabn != "")
                    {
                        MessageBox.Show(lan.Change_language_MessageText("Những người bệnh sau :\n" + _mabn + " đã thanh toán, không được thu hồi !"), d.Msg);
                        makp.Focus();
                        return;
                    }
                }
            }
            if (i_loai == 1)
            {
                string s_mabd = "", s_maql = "";
                foreach (DataRow r in tmp.Select("true", "maql"))
                {
                    if (s_maql.IndexOf(r["maql"].ToString().Trim() + ",") == -1)
                    {
                        s_maql += r["maql"].ToString().Trim() + ",";
                    }
                }
                sql  = "select distinct c.mabd, b.mabn, to_char(a.ngay,'dd/mm/yyyy') as ngay, d.ten as phieu from xxx.d_duyet a,xxx.d_hoantrall b,xxx.d_hoantract c," + user + ".d_loaiphieu d where a.id=b.idduyet and b.id=c.id and a.phieu=d.id";
                sql += " and a.done=2 and c.slthuc>0 and a.nhom=" + i_nhom + " and a.loai=3 and to_char(c.ngay,'dd/mm/yyyy')='" + s_ngay + "'";
                sql += " and a.makp=" + i_makp;
                if (s_maql != "")
                {
                    sql += " and b.maql in (" + s_maql.Substring(0, s_maql.Length - 1) + ")";
                }
                string s_ptra = "";
                foreach (DataRow r in d.get_data_mmyy(sql, s_ngay, s_ngay, true).Tables[0].Rows)
                {
                    s_mabd += r["mabd"].ToString().PadLeft(7, '0') + ",";
                    s_ptra  = "Ngày: " + r["ngay"].ToString() + "- Phiếu: " + r["phieu"].ToString() + "- MSBN: " + r["mabn"].ToString();
                }
                if (s_mabd != "")
                {
                    foreach (DataRow r in tmp.Rows)
                    {
                        if (s_mabd.IndexOf(r["mabd"].ToString().PadLeft(7, '0')) != -1)
                        {
                            bFound = true;
                            break;
                        }
                    }
                    if (bFound)
                    {
                        MessageBox.Show(phieu.Text + " có hoàn trả, không được thu hồi.\nPhải thu hồi phiếu hoàn trả trước !.\n" + s_ptra, d.Msg);
                        makp.Focus();
                        return;
                    }
                }
            }
            else if (i_loai == 2 && d.bThuhoi_kiemtra_tutruc(i_nhom))
            {
                bFound = false;
                DataRow r1;
                sql  = "select a.makp, b.sttt,b.makho,sum(b.soluong) as soluong from " + xxx + ".d_xuatsdll a," + xxx + ".d_thucbucstt b where a.id=b.id and to_char(a.ngay,'dd/mm/yyyy')='" + s_ngay + "'";
                sql += " and a.nhom=" + i_nhom + " and a.loai=" + i_loai + " and a.phieu=" + i_phieu;
                if (bIntheocstt)
                {
                    sql += " and a.makp=" + i_makp;
                }
                else
                {
                    sql += " and a.makhoa=" + i_makp;
                }
                sql += " and a.thuoc=" + i_thuoc;
                if (bBuhaophi || i_loai == 4 || bThua || i_thuoc == 2)
                {
                    sql += " and a.maql=0";
                }
                else
                {
                    sql += " and a.maql<>0";
                }
                sql += " group by b.sttt,b.makho,a.makp";
                //
                DataSet lds       = d.get_data(sql);
                string  s_makp_tt = ",";
                foreach (DataRow dr in lds.Tables[0].Rows)
                {
                    s_makp_tt += (s_makp_tt.IndexOf("," + dr["makp"].ToString() + ",") < 0) ? dr["makp"].ToString() + "," : "";
                }
                if (s_makp_tt.Trim().Trim(',') == "")
                {
                    s_makp_tt = i_makp.ToString();
                }
                else
                {
                    s_makp_tt = s_makp_tt.Trim().Trim(',');
                }
                //
                tmp = d.get_data("select makp,makho,stt,sum(tondau+slnhap-slxuat) as soluong from " + xxx + ".d_tutrucct where makp in (" + s_makp_tt.Trim().Trim(',') + ") group by makho,stt,makp").Tables[0];
                foreach (DataRow r in lds.Tables[0].Rows)
                {
                    r1 = d.getrowbyid(tmp, "makho=" + int.Parse(r["makho"].ToString()) + " and stt=" + decimal.Parse(r["sttt"].ToString()) + " and makp=" + r["makp"].ToString());
                    if (r1 != null)
                    {
                        if (decimal.Parse(r["soluong"].ToString()) > decimal.Parse(r1["soluong"].ToString()))
                        {
                            bFound = true;
                            break;
                        }
                    }
                }
                if (bFound)
                {
                    MessageBox.Show(phieu.Text + " có xuất, không được thu hồi.\nPhải thu hồi phiếu xuất tủ trực trước !", d.Msg);
                    makp.Focus();
                    return;
                }
            }
            if (bKiemtra)
            {
                if (i_loai == 1 || (i_loai == 3 && i_thuoc == 1 && !bThua))
                {
                    bFound = false;
                    DataRow   r2;
                    DataTable dthoten  = new DataTable();
                    string    s_ravien = "";
                    r2 = d.getrowbyid(dtkp, "id=" + int.Parse(makp.SelectedValue.ToString()));
                    if (r2 != null)
                    {
                        sql     = "select maql from " + user + ".xuatvien where makp='" + r2["makp"].ToString() + "'";
                        dthoten = d.get_data(sql).Tables[0];
                        bFound  = true;
                    }
                    if (bFound)
                    {
                        foreach (DataRow r in tmp.Rows)
                        {
                            r2 = d.getrowbyid(dthoten, "maql=" + decimal.Parse(r["maql"].ToString()));
                            if (r2 != null)
                            {
                                s_ravien += r["mabn"].ToString() + "\n";
                            }
                        }
                    }
                    if (s_ravien != "")
                    {
                        MessageBox.Show(lan.Change_language_MessageText("Người bệnh đã ra viện") + "\n" + s_ravien + lan.Change_language_MessageText("không được thu hồi !"), d.Msg);
                        return;
                    }
                }
            }
            Cursor = Cursors.WaitCursor;
            if (i_loai == 2 && d.bBucstt_tronso(i_nhom))
            {
                if (s_makhoa != "")
                {
                    sql = "select idduyet from " + xxx + ".d_ngayduyet where nhom=" + i_nhom + " and loai=" + i_loai + " and phieu=" + i_phieu + " and makp in (" + s_makhoa.Substring(0, s_makhoa.Length - 1) + ") and to_char(ngay,'dd/mm/yyyy')='" + s_ngay + "'";
                }
                else
                {
                    sql = "select idduyet from " + xxx + ".d_ngayduyet where nhom=" + i_nhom + " and loai=" + i_loai + " and phieu=" + i_phieu + " and makp=" + i_makp + " and to_char(ngay,'dd/mm/yyyy')='" + s_ngay + "'";
                }
                if (s_makho != "")
                {
                    sql += " and makho='" + s_makho + "'";
                }
                tmp = d.get_data(sql).Tables[0];
                string sid = "";
                foreach (DataRow r in tmp.Rows)
                {
                    sid += r["idduyet"].ToString() + ",";
                }
                string sql1 = "select to_char(a.ngay,'dd/mm/yyyy') as ngay,c.ten from xxx.d_xuatsdll a,xxx.d_bucstt b," + user + ".d_loaiphieu c where a.id=b.id and a.phieu=c.id and b.sltreo>0 ";
                if (sid != "")
                {
                    sql1 += " and a.idduyet in (" + sid.Substring(0, sid.Length - 1) + ")";
                }
                sql1 += " and a.makp=" + i_makp + " and a.nhom=" + i_nhom;
                sid   = "";

                ////Binh 23032012: comment --> chua hieu kiem tra de lam gi???
                ////foreach(DataRow r in d.get_data_mmyy(sql1, s_ngay, s_ngay, 30).Tables[0].Rows)
                ////{
                ////    sid = "Ngày " + r["ngay"].ToString() + "\nPhiếu " + r["ten"].ToString() + " có duyệt treo\nPhải thu hồi phiếu này trước !";
                ////    break;
                ////}
                ////if (sid != "")
                ////{
                ////    MessageBox.Show(sid, d.Msg);
                ////    Cursor = Cursors.Default;
                ////    return;
                ////}
                foreach (DataRow r in tmp.Rows)
                {
                    sql = "select b.* from xxx.d_xtutrucll a," + user + ".d_treoduyet b where a.id=b.id and a.idduyet=" + decimal.Parse(r["idduyet"].ToString());
                    foreach (DataRow r1 in d.get_data_mmyy(sql, s_ngay, s_ngay, 30).Tables[0].Rows)
                    {
                        if (d.get_data("select a.* from " + xxx + ".d_xuatsdll a," + xxx + ".d_bucstt b where a.id=b.id and a.idduyet=" + decimal.Parse(r1["id"].ToString()) + " and b.sttduyet=" + int.Parse(r1["stt"].ToString())).Tables[0].Rows.Count == 0)
                        {
                            d.execute_data("update " + user + ".d_treoduyet set slthuc=0 where id=" + decimal.Parse(r1["id"].ToString()) + " and stt=" + int.Parse(r1["stt"].ToString()));
                        }
                    }
                }
            }
            d.upd_duyet(s_mmyy, i_makp, i_nhom, i_loai, i_phieu, s_ngay, (bNguoiduyet_nguoithuhoi ? s_makho : ""));//s_makho
            d.upd_theodoiduyet(s_mmyy, s_ngay, i_nhom, i_loai, i_makp, 1);
            d.upd_thuhoi(s_mmyy, i_nhom, s_ngay, i_loai, i_makp, i_userid, i_phieu);
            sql  = "select distinct a.id, to_char(a.ngayylenh,'dd/mm/yyyy') as ngayylenh from " + xxx + ".d_xuatsdll a," + xxx + "." + tenfile + " b where a.id=b.id and to_char(a.ngay,'dd/mm/yyyy')='" + s_ngay + "'";
            sql += " and a.nhom=" + i_nhom + " and a.loai=" + i_loai + " and a.phieu=" + i_phieu;
            if (i_loai == 2)
            {
                if (bIntheocstt)
                {
                    sql += " and a.makp=" + i_makp;
                }
                else
                {
                    sql += " and a.makhoa=" + i_makp;
                }
            }
            else
            {
                sql += " and a.makhoa=" + i_makp;
            }
            sql += " and a.thuoc=" + i_thuoc;
            if (b1kho)
            {
                sql += " and a.lydo=" + int.Parse(s_makho.Substring(0, s_makho.Length - 1));
            }
            if (bBuhaophi || i_loai == 4 || bThua || i_thuoc == 2)
            {
                sql += " and a.maql=0";
            }
            else
            {
                sql += " and a.maql<>0";
            }
            foreach (DataRow r in d.get_data(sql).Tables[0].Rows)
            {
                d.del(s_mmyy, tenfile, decimal.Parse(r["id"].ToString()), dtll, i_loai, bBuhaophi, i_nhom, i_phieu, s_ngay, i_userid, bDuyettreole, r["ngayylenh"].ToString());
            }
            //
            string file = (i_loai == 2) ? "d_thucbucstt" : "d_thucxuat";

            sql  = "select distinct a.id from " + xxx + ".d_xuatsdll a," + xxx + "." + file + " b where a.id=b.id and to_char(a.ngay,'dd/mm/yyyy')='" + s_ngay + "'";
            sql += " and a.nhom=" + i_nhom + " and a.loai=" + i_loai + " and a.phieu=" + i_phieu;
            if (i_loai == 2)
            {
                if (bIntheocstt)
                {
                    sql += " and a.makp=" + i_makp;
                }
                else
                {
                    sql += " and a.makhoa=" + i_makp;
                }
            }
            else
            {
                sql += " and a.makhoa=" + i_makp;
            }
            sql += " and a.thuoc=" + i_thuoc;
            if (b1kho)
            {
                sql += " and a.lydo=" + int.Parse(s_makho.Substring(0, s_makho.Length - 1));
            }
            if (bBuhaophi || i_loai == 4 || bThua || i_thuoc == 2)
            {
                sql += " and a.maql=0";
            }
            else
            {
                sql += " and a.maql<>0";
            }
            foreach (DataRow r in d.get_data(sql).Tables[0].Rows)
            {
                d.execute_data("delete from " + xxx + "." + file + " where id=" + decimal.Parse(r["id"].ToString()));
            }
            //
            dtct.Clear();
            sql = "select * from " + user + ".d_dmkho where nhom=" + i_nhom;
            if (s_makho != "")
            {
                sql += " and id in (" + s_makho.Substring(0, s_makho.Length - 1) + ")";
            }
            foreach (DataRow r in d.get_data(sql).Tables[0].Rows)
            {
                d.execute_data("delete from " + xxx + ".d_daduyet where nhom=" + i_nhom + " and to_char(ngay,'dd/mm/yyyy')='" + s_ngay + "' and makp=" + i_makp + " and loai=" + i_loai + " and phieu=" + i_phieu + " and makho=" + int.Parse(r["id"].ToString()));
            }
            if (d.bKiemtra_duyet(i_nhom))
            {
                d.upd_tonkho(s_mmyy, i_nhom, 0);
            }
            int itable = d.tableid(s_mmyy, "d_ngayduyet");

            d.upd_eve_tables(s_mmyy, itable, i_userid, "del");
            d.upd_eve_upd_del(s_mmyy, itable, i_userid, "del", i_nhom.ToString() + "^" + i_loai.ToString() + "^" + i_makp.ToString() + "^" + s_ngay + "^0^" + i_phieu.ToString() + "^" + s_makho + "^0");

            Cursor = Cursors.Default;
            if (d.bTinnhan(i_nhom))
            {
                DataRow r = d.getrowbyid(dtkp, "id=" + int.Parse(makp.SelectedValue.ToString()));
                if (r != null)
                {
                    if (r["computer"].ToString() != "")
                    {
                        d.netsend(d.sDomain(i_nhom), r["computer"].ToString().Trim(), s_noidung + " KHOA " + m.khongdau(makp.Text) + " PHIEU " + m.khongdau(phieu.Text) + " DA THU HOI !");
                    }
                }
            }
            //
            MessageBox.Show(lan.Change_language_MessageText("Đã thu hồi xong."), lan.Change_language_MessageText("Thu hồi"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            d.close(); this.Close();
        }
Exemple #11
0
        private void butLuu_Click(object sender, System.EventArgs e)
        {
            butLuu.Enabled = false;
            ds.AcceptChanges();
            DataRow r1, r2;

            foreach (DataRow r in ds.Tables[0].Select("soluong>0"))
            {
                r1 = m.getrowbyid(dtdt, "doituong='" + r["doituong"].ToString() + "'");
                if (r1 != null)
                {
                    r2 = m.getrowbyid(dtnguon, "ten='" + r["nguon"].ToString() + "'");
                    if (r2 != null)
                    {
                        r["madoituong"] = r1["madoituong"].ToString();
                        r["manguon"]    = r2["id"].ToString();
                    }
                }
            }
            string s = "", sql;
            int    tt = 1;

            foreach (DataRow r in ds.Tables[0].Select("soluong>0"))
            {
                sql = "manguon=" + int.Parse(r["manguon"].ToString()) + " and id=" + int.Parse(r["mabd"].ToString());
                r1  = m.getrowbyid(dsdm.Tables[0], sql);
                if (r1 == null)
                {
                    s = s + r["ten"].ToString().Trim() + " " + r["dang"].ToString().Trim() + "\n";
                }
                else
                {
                    if (decimal.Parse(r1["soluong"].ToString()) < decimal.Parse(r["soluong"].ToString()))
                    {
                        s = s + r["ten"].ToString().Trim() + " " + r["dang"].ToString().Trim() + "\n";
                    }
                    r["makho"] = r1["makho"].ToString();
                    r["stt"]   = tt++;
                }
            }
            if (s != "")
            {
                MessageBox.Show(lan.Change_language_MessageText("Những mặt hàng sau không đủ tồn :") + "\n" + s);
                dataGrid2.Focus();
                return;
            }
            if (!bNew)
            {
                string xxx = user + mmyy;
                foreach (DataRow r in d.get_data("select a.*,b.manguon,b.giaban,b.giamua,a.soluong*b.giamua as sotien,b.gianovat, a.gia_bh from " + xxx + ".d_thucxuat a," + xxx + ".d_theodoi b, " + user + ".d_dmbd c where a.sttt=b.id and a.id=" + l_id).Tables[0].Rows)
                {
                    d.upd_tonkhoct_thucxuat(d.delete, mmyy, makp, loai, 1, decimal.Parse(r["sttt"].ToString()), int.Parse(r["makho"].ToString()), int.Parse(r["manguon"].ToString()), int.Parse(r["mabd"].ToString()), decimal.Parse(r["soluong"].ToString()));
                    d.upd_theodoicongno(d.delete, s_mabn, l_mavaovien, l_maql, l_idkhoa, int.Parse(r["madoituong"].ToString()), decimal.Parse(r["sotien"].ToString()), "thuoc");
                    d.upd_tienthuoc(d.delete, mmyy, l_id, s_mabn, l_mavaovien, l_maql, l_idkhoa, ngay, makhoa, loai, int.Parse(r["madoituong"].ToString()), int.Parse(r["mabd"].ToString()), decimal.Parse(r["soluong"].ToString()), decimal.Parse(r["giaban"].ToString()), decimal.Parse(r["giamua"].ToString()), decimal.Parse(r["gianovat"].ToString()), i_traituyen, decimal.Parse(r["gia_bh"].ToString()), "");
                }
                d.execute_data("delete from " + xxx + ".d_xuatsdct where id=" + l_id);
                d.execute_data("delete from " + xxx + ".d_thucxuat where id=" + l_id);
            }
            d.upd_dausinhton(mmyy, l_id, l_idkhoa, l_id, ngay, "", "", 0, 0, "", 0, 0, "", "", "", "");
            d.upd_xtutrucll(mmyy, l_id, l_duyet, s_mabn, l_mavaovien, l_maql, l_idkhoa, s_ngayvv, 1);
            foreach (DataRow r in ds.Tables[0].Rows)
            {
                d.upd_xtutrucct(mmyy, l_id, int.Parse(r["stt"].ToString()), int.Parse(r["madoituong"].ToString()), int.Parse(r["makho"].ToString()), int.Parse(r["mabd"].ToString()), decimal.Parse(r["soluong"].ToString()), 0, "", int.Parse(r["manguon"].ToString()), 0, 1, 1);
            }
            d.upd_xuatsdll(mmyy, l_id, i_nhom, s_mabn, l_mavaovien, l_maql, l_idkhoa, ngay, loai, phieu, makp, i_userid, l_id, 1, makhoa, 0, 0, l_mavp.ToString(), ngay, 0, "");
            d.get_xuatsdct_cstt(mmyy, ds.Tables[0].Select("soluong>0", "stt"), makp, makhoa, 0, l_id, s_mabn, l_mavaovien, l_maql, l_idkhoa, loai, 1, ngay, i_nhom, ngay, i_traituyen, "");
            butKetthuc.Focus();
        }
Exemple #12
0
        private void butChon_Click(object sender, System.EventArgs e)
        {
            if (makp.SelectedIndex == -1)
            {
                makp.Focus(); return;
            }
            if (phieu.SelectedIndex == -1)
            {
                phieu.Focus(); return;
            }
            s_phieu = "";
            if (phieudutru.CheckedItems.Count > 0)
            {
                for (int i = 0; i < phieudutru.Items.Count; i++)
                {
                    if (phieudutru.GetItemChecked(i))
                    {
                        s_phieu += dtph.Rows[i]["id"].ToString().Trim() + ",";
                    }
                }
            }
            s_tu    = tu.Text; s_den = den.Text; i_phieu = int.Parse(phieu.SelectedValue.ToString()); i_makp = int.Parse(makp.SelectedValue.ToString());
            s_tenkp = makp.Text;
            if (d.get_duyet(s_mmyy, i_makp, i_nhom, i_loai, i_phieu, s_ngay, s_makho))
            {
                MessageBox.Show(lan.Change_language_MessageText("Ngày") + " " + s_ngay + "\n" + lan.Change_language_MessageText("Khoa") + " " + makp.Text + "\n" + lan.Change_language_MessageText("Phiếu") + " " + phieu.Text + "\n" + lan.Change_language_MessageText("Đã duyệt !"), d.Msg);
                return;
            }
            bool bChieu_sang = m.bChieu_sang;

            if (bChieu_sang)
            {
                DataRow r1, r2;
                r2 = d.getrowbyid(dtphieu, "id=" + int.Parse(phieu.SelectedValue.ToString()));
                if (r2 != null)
                {
                    if (r2["buoi"].ToString() == "0")
                    {
                        r1 = d.getrowbyid(dtkp, "id=" + int.Parse(makp.SelectedValue.ToString()));
                        if (r1 != null)
                        {
                            if (d.get_ttngay(s_ngay, r1["makp"].ToString()))
                            {
                                MessageBox.Show(lan.Change_language_MessageText("Ngày") + " " + s_ngay + " " + lan.Change_language_MessageText("viện phí đã in danh sách thu tiền") + "\n" + lan.Change_language_MessageText("Yêu cầu chọn phiếu buổi chiều !"), d.Msg);
                                return;
                            }
                        }
                    }
                }
            }
            if (chkChuyen.Checked)
            {
                string sql = "select id from " + xxx + ".d_duyet ";
                sql += " where done=0 and nhom=" + i_nhom + " and loai=" + i_loai;
                sql += " and makhoa=" + i_makp;
                sql += " and ngay between to_date('" + s_tu + "','" + f_ngay + "') and to_date('" + s_den + "','" + f_ngay + "')";
                if (s_phieu != "")
                {
                    sql += " and phieu in (" + s_phieu.Substring(0, s_phieu.Length - 1) + ")";
                }
                foreach (DataRow r in d.get_data(sql).Tables[0].Rows)
                {
                    d.execute_data("update " + xxx + ".d_duyet set done=1 where id=" + decimal.Parse(r["id"].ToString()));
                }
            }
            DataTable dttam = new DataTable();

            dttam = d.get_data("select computer from " + user + ".d_danglaysolieu where makp=" + i_makp +
                               " and phieu=" + i_phieu + " and to_char(ngay,'dd/mm/yyyy')='" + s_ngay + "' and computer<>'" + System.Environment.MachineName + "'").Tables[0];
            if (dttam.Rows.Count > 0)
            {
                MessageBox.Show(lan.Change_language_MessageText("Phiếu này đang lấy số liệu duyệt tại máy ") + dttam.Rows[0][0].ToString() + lan.Change_language_MessageText(".\n Vui lòng chọn phiếu khác."));
                return;
            }
            d.upd_danglaysolieu(i_makp, i_phieu, s_ngay, i_userid);
            d.close(); this.Close();
        }
Exemple #13
0
        private void butLuu_Click(object sender, System.EventArgs e)
        {
            ds.AcceptChanges();
            DataRow r1, r2;

            foreach (DataRow r in ds.Tables[0].Select("soluong>0"))
            {
                r1 = m.getrowbyid(dtdt, "doituong='" + r["doituong"].ToString() + "'");
                if (r1 != null)
                {
                    r2 = m.getrowbyid(dtnguon, "ten='" + r["nguon"].ToString() + "'");
                    if (r2 != null)
                    {
                        r["madoituong"] = r1["madoituong"].ToString();
                        r["manguon"]    = r2["id"].ToString();
                    }
                }
            }
            string s = "", sql;
            int    tt = 1;

            foreach (DataRow r in ds.Tables[0].Select("soluong>0"))
            {
                sql = "manguon=" + int.Parse(r["manguon"].ToString()) + " and id=" + int.Parse(r["mabd"].ToString());
                r1  = m.getrowbyid(dsdm.Tables[0], sql);
                if (r1 == null)
                {
                    s = s + r["ten"].ToString().Trim() + " " + r["dang"].ToString().Trim() + "\n";
                }
                else
                {
                    if (decimal.Parse(r1["soluong"].ToString()) < decimal.Parse(r["soluong"].ToString()))
                    {
                        s = s + r["ten"].ToString().Trim() + " " + r["dang"].ToString().Trim() + "\n";
                    }
                    r["makho"] = r1["makho"].ToString();
                    r["stt"]   = tt++;
                }
            }
            if (s != "")
            {
                MessageBox.Show("Những mặt hàng sau không đủ tồn :\n" + s);
                dataGrid2.Focus();
                return;
            }
            if (!bNew)
            {
                foreach (DataRow r in d.get_data(mmyy, "select * from d_thucxuat where id=" + l_id).Tables[0].Rows)
                {
                    d.upd_tonkhoct_thucxuat(d.delete, mmyy, makp, loai, 1, long.Parse(r["sttt"].ToString()), int.Parse(r["makho"].ToString()), int.Parse(r["manguon"].ToString()), int.Parse(r["nhomcc"].ToString()), int.Parse(r["mabd"].ToString()), r["handung"].ToString(), r["losx"].ToString(), decimal.Parse(r["soluong"].ToString()), decimal.Parse(r["sotien"].ToString()), decimal.Parse(r["giaban"].ToString()), decimal.Parse(r["giamua"].ToString()));
                    d.upd_theodoicongno(d.delete, s_mabn, l_maql, l_idkhoa, int.Parse(r["madoituong"].ToString()), decimal.Parse(r["sotien"].ToString()), "thuoc");
                    d.upd_tienthuoc(d.delete, mmyy, s_mabn, l_maql, l_idkhoa, ngay, makhoa, loai, int.Parse(r["madoituong"].ToString()), int.Parse(r["mabd"].ToString()), decimal.Parse(r["soluong"].ToString()), decimal.Parse(r["sotien"].ToString()), decimal.Parse(r["giaban"].ToString()), decimal.Parse(r["giamua"].ToString()));
                }
                d.execute_data(mmyy, "delete from d_xuatsdct where id=" + l_id);
                d.execute_data(mmyy, "delete from d_thucxuat where id=" + l_id);
            }
            d.upd_dausinhton(l_id, l_idkhoa, l_id, ngay, "", "", 0, 0, "", 0, 0, "", "", "");
            d.upd_xtutrucll(l_id, l_duyet, s_mabn, l_maql, l_idkhoa);
            foreach (DataRow r in ds.Tables[0].Rows)
            {
                d.upd_xtutrucct(l_id, int.Parse(r["stt"].ToString()), int.Parse(r["madoituong"].ToString()), int.Parse(r["makho"].ToString()), int.Parse(r["mabd"].ToString()), decimal.Parse(r["soluong"].ToString()), 0, "", int.Parse(r["manguon"].ToString()), 0);
            }
            d.upd_xuatsdll(l_id, i_nhom, s_mabn, l_maql, l_idkhoa, ngay, loai, phieu, makp, mmyy, i_userid, l_id, 1, makhoa, 0, 0, "");
            d.get_xuatsdct_cstt(mmyy, ds.Tables[0].Select("soluong>0", "stt"), makp, makhoa, 0, l_id, s_mabn, l_maql, l_idkhoa, loai, 1, ngay);
            butKetthuc.Focus();
        }
Exemple #14
0
        private void f_tonghop_duocbv()
        {
            Cursor = Cursors.WaitCursor;
            decimal sum = 0, st = 0;
            DataSet tmp = d.get_sotien_dbv(i_nhom, tu.Text, den.Text);

            foreach (DataRow r in ds.Tables[0].Select("ma in (3,4,5,6,7,8)"))
            {
                st = 0;
                foreach (DataRow r1 in tmp.Tables[0].Select("stt=" + int.Parse(r["ma"].ToString())))
                {
                    st += decimal.Parse(r1["sotien"].ToString());
                }
                r["soluong"] = st / 1000;
            }
            foreach (DataRow r in tmp.Tables[0].Rows)
            {
                sum += decimal.Parse(r["sotien"].ToString());
            }
            DataRow r2 = d.getrowbyid(ds.Tables[0], "ma=1");

            if (r2 != null)
            {
                r2["soluong"] = sum / 1000;
            }
            tmp = d.get_sothuoc_dbv(i_nhom, tu.Text, den.Text);
            r2  = d.getrowbyid(ds.Tables[0], "ma=21");
            if (r2 != null)
            {
                r2["soluong"] = tmp.Tables[0].Rows.Count;
            }
            r2 = d.getrowbyid(ds.Tables[0], "ma=23");
            if (r2 != null)
            {
                r2["soluong"] = tmp.Tables[0].Select("id=1").Length;
            }
            r2 = d.getrowbyid(ds.Tables[0], "ma=24");
            if (r2 != null)
            {
                r2["soluong"] = tmp.Tables[0].Select("id=2").Length;
            }
            tmp = d.get_soluong_dichtruyen(i_nhom, tu.Text, den.Text);
            sum = 0;
            foreach (DataRow r in ds.Tables[0].Select("ma in (12,13,14)"))
            {
                st = 0;
                foreach (DataRow r1 in tmp.Tables[0].Select("stt=" + int.Parse(r["ma"].ToString())))
                {
                    st += decimal.Parse(r1["soluong"].ToString()) * decimal.Parse(d.so_chu(r1["hamluong"].ToString()));
                }
                r["soluong"] = st / 1000;
                if (r["ma"].ToString() == "14")
                {
                    sum += st;
                }
            }
            r2 = d.getrowbyid(ds.Tables[0], "ma=13");
            if (r2 != null)
            {
                r2["soluong"] = decimal.Parse(r2["soluong"].ToString()) + sum / 1000;
            }
            sum = 0;
            foreach (DataRow r in ds.Tables[0].Select("ma in (12,13)"))
            {
                sum += decimal.Parse(r["soluong"].ToString());
            }
            r2 = d.getrowbyid(ds.Tables[0], "ma=10");
            if (r2 != null)
            {
                r2["soluong"] = sum;
            }
            foreach (DataRow r in ds.Tables[0].Rows)
            {
                d.execute_data("update " + user + ".dm_07 set soluong=" + decimal.Parse(r["soluong"].ToString()) + " where ma=" + int.Parse(r["ma"].ToString()));
            }
            butKHTH.Enabled = true;
            Cursor          = Cursors.Default;
        }