Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridView1.CurrentCell == null)
                {
                    return;
                }
                DataTable tb = (DataTable)dataGridView1.DataSource;

                //分组处方
                string[] GroupbyField_mb           = { "HJID" };
                string[] ComputeField_mb           = { "金额" };
                string[] CField_mb                 = { "sum" };
                TrasenFrame.Classes.TsSet xcset_mb = new TrasenFrame.Classes.TsSet();
                xcset_mb.TsDataTable = tb;
                DataTable tbcf_mb = xcset_mb.GroupTable(GroupbyField_mb, ComputeField_mb, CField_mb, " 项目id>0 and 选择=true ");
                if (tbcf_mb.Rows.Count == 0)
                {
                    MessageBox.Show("请选择处方", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                DateTime djsj = DateManager.ServerDateTimeByDBType(InstanceForm.BDatabase);
                for (int x = 0; x <= tbcf_mb.Rows.Count - 1; x++)
                {
                    string ssql   = "update mz_hjb set bshbz=1,shy=" + InstanceForm.BCurrentUser.EmployeeId + " , SHSJ='" + djsj + "' where hjid='" + tbcf_mb.Rows[x]["hjid"].ToString() + "' and bshbz=0 ";
                    int    ncount = InstanceForm.BDatabase.DoCommand(ssql);
                    if (ncount == 0)
                    {
                        throw new Exception("请刷新处方后再试,可能部分处方已被确认");
                    }

                    DataRow[] rows1 = tb.Select("hjid='" + tbcf_mb.Rows[x]["hjid"].ToString() + "'");
                    for (int i = 0; i <= rows1.Length - 1; i++)
                    {
                        rows1[i]["审核"] = "1";
                    }
                }

                MessageBox.Show("审核成功");
                DataTable Tab = GetPresc(Dqcf.brxxid, Dqcf.ghxxid, "", _menuTag.Jgbm);
                AddPresc(Tab);
            }
            catch (System.Exception err)
            {
                MessageBox.Show(err.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        /// <summary>
        /// 在网格中显示处方
        /// </summary>
        /// <param name="tb"></param>
        private void AddPresc(DataTable tb)
        {
            DataTable tbmx  = tb.Clone();
            decimal   sumje = 0;

            string[] GroupbyField = { "CFID" };

            string[] ComputeField           = { "金额" };
            string[] CField                 = { "sum" };
            TrasenFrame.Classes.TsSet xcset = new TrasenFrame.Classes.TsSet();
            xcset.TsDataTable = tb;
            DataTable tbcf = xcset.GroupTable(GroupbyField, ComputeField, CField, "序号<>'小计'");

            for (int i = 0; i <= tbcf.Rows.Count - 1; i++)
            {
                DataRow[] rows = tb.Select(" CFID='" + tbcf.Rows[i]["CFID"].ToString().Trim() + "' ");
                for (int j = 0; j <= rows.Length - 1; j++)
                {
                    DataRow row = tb.NewRow();
                    row = rows[j];
                    if (rows[j]["用法"].ToString() != "" && rows[j]["用法"].ToString() != "0")//Add By Zj 2012-12-28 显示上拼接用法 株洲中医院提出
                    {
                        row["项目名称"] = rows[j]["项目名称"].ToString() + "(" + rows[j]["用法"].ToString() + ")";
                    }
                    row["序号"] = j + 1;
                    tbmx.ImportRow(row);
                }
                DataRow sumrow = tbmx.NewRow();
                sumrow["序号"] = "小计";
                decimal je = Math.Round(Convert.ToDecimal(tbcf.Rows[i]["金额"]), 2);
                sumrow["金额"] = je.ToString("0.00");
                sumje        = sumje + je;
                //sumrow["发票号"] = tbcf.Rows[i]["发票号"];
                sumrow["CFID"] = tbcf.Rows[i]["CFID"];
                tbmx.Rows.Add(sumrow);
            }
            tbmx.AcceptChanges();
            dataGridView1.DataSource   = tbmx;
            dataGridView1.CurrentCell  = null;
            toolStripStatusLabel1.Text = "金额:" + sumje.ToString("0.00");
        }
Пример #3
0
        private void AddPresc(DataTable tb)
        {
            decimal   sumje = 0;
            DataTable tbmx  = tb.Clone();

            string[] GroupbyField           = { "HJID" };
            string[] ComputeField           = { "金额" };
            string[] CField                 = { "sum" };
            TrasenFrame.Classes.TsSet xcset = new TrasenFrame.Classes.TsSet();
            xcset.TsDataTable = tb;
            DataTable tbcf = xcset.GroupTable(GroupbyField, ComputeField, CField, "序号<>'小计'  ");
            bool      b_ks = false;

            pb.Visible = true;
            pb.Value   = 0;
            pb.Maximum = tbcf.Rows.Count;
            pb.Minimum = 0;
            for (int i = 0; i <= tbcf.Rows.Count - 1; i++)
            {
                pb.Value = pb.Value + 1;
                decimal zbyje = 0;

                DataRow[] rows = tb.Select("HJID='" + tbcf.Rows[i]["hjid"].ToString().Trim() + "'");
                for (int j = 0; j <= rows.Length - 1; j++)
                {
                    DataRow row = tb.NewRow();
                    row         = rows[j];
                    row["序号"]   = j + 1;
                    row["开嘱时间"] = ' ' + Convert.ToDateTime(rows[j]["划价日期"]).ToString("MM-dd HH:mm");
                    if (row["自备药"].ToString() == "1")
                    {
                        row["医嘱内容"] = row["医嘱内容"] + " 【自备】";
                    }
                    if (row["处方分组序号"].ToString() == "1")
                    {
                        b_ks = true; row["医嘱内容"] = "┌" + row["医嘱内容"].ToString();
                    }
                    if (row["处方分组序号"].ToString() == "2" && b_ks == true)
                    {
                        row["医嘱内容"] = "│" + row["医嘱内容"].ToString();
                    }
                    if (row["处方分组序号"].ToString() == "-1" && b_ks == true)
                    {
                        b_ks = false; row["医嘱内容"] = "└" + row["医嘱内容"].ToString();
                    }
                    if (row["皮试标志"].ToString() == "0" && row["项目来源"].ToString() == "1")
                    {
                        row["医嘱内容"] = row["医嘱内容"] + " 【皮试】";
                    }
                    if (row["皮试标志"].ToString() == "1")
                    {
                        row["医嘱内容"] = row["医嘱内容"] + " 【-】";
                    }
                    if (row["皮试标志"].ToString() == "2")
                    {
                        row["医嘱内容"] = row["医嘱内容"] + " 【+】";
                    }
                    if (row["皮试标志"].ToString() == "3")
                    {
                        row["医嘱内容"] = row["医嘱内容"] + " 【免试】";
                    }
                    if (row["皮试标志"].ToString() == "9")
                    {
                        row["医嘱内容"] = row["医嘱内容"] + " 【皮试液】";
                    }


                    if (rows[j]["自备药"].ToString() == "1")
                    {
                        zbyje += Convert.ToDecimal(rows[j]["金额"]);
                    }

                    tbmx.ImportRow(row);
                }
                DataRow sumrow = tbmx.NewRow();
                sumrow["序号"] = "小计";

                decimal je = Math.Round(Convert.ToDecimal(tbcf.Rows[i]["金额"]), 2) - zbyje; //modify by wangzhi 2010-12-16 处方金额减去自备药金额
                sumrow["金额"]   = je.ToString("0.00");
                sumje          = sumje + je;
                sumrow["hjid"] = tbcf.Rows[i]["hjid"];
                tbmx.Rows.Add(sumrow);
            }
            tbmx.AcceptChanges();
            dataGridView1.DataSource  = tbmx;
            dataGridView1.CurrentCell = null;
            pb.Visible = false;
        }
Пример #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            DateTime  date1 = DateTime.Parse(this.dateTimePicker1.Value.ToShortDateString() + "  00:00:00");
            DateTime  date2 = DateTime.Parse(this.dateTimePicker2.Value.AddDays(1).ToShortDateString() + "  00:00:00");
            DataTable tb    = (DataTable)this.dataGridView2.DataSource;

            if (tb == null)
            {
                MessageBox.Show("请先查询");
                return;
            }
            string[] GroupbyField1           = { "cjid", "deptly", "ywlx", "deptly", "zxdw", "单价", "dwbl", "wldw" }; //
            string[] ComputeField1           = { "借药数量", "还药数量", "暂存上缴数量" };                                         //
            string[] CField1                 = { "sum", "sum", "sum" };                                              //
            TrasenFrame.Classes.TsSet tsset1 = new TrasenFrame.Classes.TsSet();
            tsset1.TsDataTable = tb;
            DataTable tbfl = tsset1.GroupTable(GroupbyField1, ComputeField1, CField1, "");

            if (tbfl.Rows.Count == 0)
            {
                return;
            }
            int     deptly = InstanceForm.BCurrentDept.WardDeptId == 0 ? InstanceForm.BCurrentDept.DeptId : InstanceForm.BCurrentDept.WardDeptId;
            decimal zsl    = 0;
            decimal xj_kcl = 0;
            Guid    sjpc   = Guid.NewGuid();

            InstanceForm.BDatabase.BeginTransaction();
            try
            {
                //暂存数量+还药数量-借药数量
                for (int i = 0; i < tbfl.Rows.Count; i++)
                {
                    Guid sjid = Guid.NewGuid();
                    zsl = decimal.Parse(tbfl.Rows[i]["暂存上缴数量"].ToString()) + decimal.Parse(tbfl.Rows[i]["还药数量"].ToString())
                          - decimal.Parse(tbfl.Rows[i]["借药数量"].ToString());
                    xj_kcl = decimal.Parse(tbfl.Rows[i]["借药数量"].ToString()) - decimal.Parse(tbfl.Rows[i]["还药数量"].ToString());
                    //插入Zy_zcySjjl上缴记录
                    string sql = string.Format(@"insert into  dbo.Zy_zcySjjl (
                                                         sjid, sjrq, sjr, kssj, jssj, lyks, wldw, cjid, dwbl, zxdw, lsj, zsl, je, jysl, hysl, zcsjsl, sjpc,jlzt)
                                                          values
                                                        ('{0}',GETDATE(),{1},'{2}','{3}',{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},'{15}',{16})"
                                               , sjid, FrmMdiMain.CurrentUser.EmployeeId, date1, date2, deptly,
                                               int.Parse(tbfl.Rows[i]["wldw"].ToString()), int.Parse(tbfl.Rows[i]["cjid"].ToString()),
                                               int.Parse(tbfl.Rows[i]["dwbl"].ToString()),
                                               int.Parse(tbfl.Rows[i]["zxdw"].ToString()),
                                               decimal.Parse(tbfl.Rows[i]["单价"].ToString()), zsl, zsl * decimal.Parse(tbfl.Rows[i]["单价"].ToString()),
                                               decimal.Parse(tbfl.Rows[i]["借药数量"].ToString()), decimal.Parse(tbfl.Rows[i]["还药数量"].ToString()),
                                               decimal.Parse(tbfl.Rows[i]["暂存上缴数量"].ToString()), sjpc, 0
                                               );
                    InstanceForm.BDatabase.DoCommand(sql);
                    //更新zy_zcydjxx表
                    DataRow[] rowupdate = tb.Select(" cjid=" + tbfl.Rows[i]["cjid"].ToString() + " and wldw=" + tbfl.Rows[i]["wldw"].ToString()
                                                    + "  and ywlx=" + tbfl.Rows[i]["ywlx"].ToString() + " and deptly=" + tbfl.Rows[i]["deptly"].ToString()
                                                    + " and 单价=" + tbfl.Rows[i]["单价"].ToString() + "  and zxdw=" + tbfl.Rows[i]["zxdw"].ToString() +
                                                    " and dwbl=" + tbfl.Rows[i]["dwbl"].ToString());
                    string updatesql = " id in (";
                    for (int j = 0; j < rowupdate.Length; j++)
                    {
                        updatesql += " '" + rowupdate[j]["id"] + "',";
                    }
                    if (updatesql != " id in (")
                    {
                        updatesql = updatesql.Substring(0, updatesql.Length - 1) + ")";
                        updatesql = "update zy_zcydjxx set sjid='" + sjid + "' where " + updatesql;
                        InstanceForm.BDatabase.DoCommand(updatesql);
                    }
                    //更新库存
                    updatesql = @"update Zy_ZcyKcmx  set kcl=a.kcl+(" + xj_kcl + ")*a.dwbl/" + tbfl.Rows[i]["dwbl"].ToString() +
                                ", zcjs=zcjs-(" + xj_kcl + ")*a.dwbl/" + tbfl.Rows[i]["dwbl"].ToString() +
                                "  from Zy_ZcyKcmx a "
                                + " where  cjid='" + tbfl.Rows[i]["cjid"].ToString() + "' and ksid=" + tbfl.Rows[i]["deptly"].ToString()
                                + "  and yfksid=" + tbfl.Rows[i]["wldw"].ToString();
                    InstanceForm.BDatabase.DoCommand(updatesql);
                }
                InstanceForm.BDatabase.CommitTransaction();
                MessageBox.Show(" 操作成功!");
                button1_Click(null, null);
            }
            catch (Exception ex)
            {
                InstanceForm.BDatabase.RollbackTransaction();
                MessageBox.Show(ex.Message);
            }
        }
Пример #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            SystemCfg cfg7117    = new SystemCfg(7117);
            string    execdeptid = cfg7117.Config.Trim();
            DataTable Yptable1   = (DataTable)this.dataGridView1.DataSource;
            DataTable Yptable    = Yptable1.Copy();

            if (Yptable == null || Yptable.Rows.Count == 0)
            {
                return;
            }
            Yptable.Rows.Remove(Yptable.Rows[Yptable.Rows.Count - 1]);
            //   myFunc.SendYP(Yptable, InstanceForm.BCurrentDept.WardId, InstanceForm.BCurrentUser.EmployeeId, DateManager.ServerDateTimeByDBType(FrmMdiMain.Database), Convert.ToInt64(execdeptid), 0, FrmMdiMain.Jgbm);
            string[] GroupbyField1           = { "EXECDEPT_ID" };
            string[] ComputeField1           = { };
            string[] CField1                 = { };
            TrasenFrame.Classes.TsSet tsset1 = new TrasenFrame.Classes.TsSet();
            tsset1.TsDataTable = Yptable;
            DataTable tbfl = tsset1.GroupTable(GroupbyField1, ComputeField1, CField1, "");

            if (MessageBox.Show("暂存数据上传【可能】需要几分钟甚至更长时间, 您确定要处理吗?\r\n点击是【处理】,请您耐心等待 ||  否【不处理】”?\n",
                                "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.No)
            {
                return;
            }


            try
            {
                //生成暂存药品统领单 这部可以省略
                for (int i = 0; i < tbfl.Rows.Count; i++)
                {
                    // writelog("搜索内存表");
                    Yptable.DefaultView.RowFilter = "EXECDEPT_ID=" + tbfl.Rows[i]["EXECDEPT_ID"].ToString();
                    DataTable tbtemp = Yptable.DefaultView.ToTable();
                    // writelog("搜索内存表完毕");
                    myFunc.SendYPzcgl(tbtemp, FrmMdiMain.CurrentDept.WardId, FrmMdiMain.CurrentUser.EmployeeId, DateManager.ServerDateTimeByDBType(FrmMdiMain.Database), Convert.ToInt64(tbfl.Rows[i]["EXECDEPT_ID"].ToString()), 0, FrmMdiMain.Jgbm, 5);
                }

                button1_Click(null, null);
                MessageBox.Show("发送成功!");
                this.wizard1.NavigateNext();
                button1_Click(null, null);
            }
            catch (Exception ex)
            {
                button1_Click(null, null);
                MessageBox.Show(ex.Message);
            }
            #region
            //Cursor.Current =PubStaticFun.WaitCursor();
            //FrmMdiMain.Database.BeginTransaction();
            //try
            //{
            //    writelog( "开始更新费用表");
            //    for (int i = 0; i < Yptable.Rows.Count; i++)
            //    {
            //        string update = "update ZY_FEE_SPECI set  bz=cast(EXECDEPT_ID as varchar(20)),fy_bit=1,FY_DATE=getdate(),FY_USER ="******" , EXECDEPT_ID=" + execdeptid + " where id= '" + Yptable.Rows[i]["zy_id"].ToString() + "'";
            //        //sqlerr = update;
            //        FrmMdiMain.Database.DoCommand(update);
            //    }
            //    writelog( "更新费用表完毕");
            //    //生成发药信息
            //    Guid group_id = Guid.Empty;
            //    ZcyBill.Cszcyp(FrmMdiMain.Database, Yptable, InstanceForm.BCurrentDept.WardDeptId.ToString(), InstanceForm.BCurrentUser.EmployeeId, long.Parse(execdeptid), DateManager.ServerDateTimeByDBType(InstanceForm.BDatabase), FrmMdiMain.Jgbm, out  group_id);
            //    writelog( "生成暂存药品");
            //    //删除领药消息 add by zouchihua 2012-12-15
            //    string udpatess = " update ZY_APPLY_DRUG set DELETE_BIT=1,GROUP_ID='" + group_id + "' where APPLY_NURSE=" + FrmMdiMain.CurrentUser.EmployeeId + " and DELETE_BIT=0 and EXECDEPT_ID=" + execdeptid + " ";

            //    FrmMdiMain.Database.DoCommand(udpatess);
            //    Cursor.Current = Cursors.Default;
            //    FrmMdiMain.Database.CommitTransaction();
            //    button1_Click(null, null);
            //    MessageBox.Show("发送成功!");
            //    this.wizard1.NavigateNext();
            //    button1_Click(null, null);

            //}
            //catch(Exception ex) {
            //    FrmMdiMain.Database.RollbackTransaction();
            //    Cursor.Current = Cursors.Default;
            //    MessageBox.Show(ex.Message);
            //}
            #endregion
        }
Пример #6
0
        //单病种
        public static void dbz_yb_js(Guid brxxid, Guid ghxxid, string mzh, User _BCurrentUser, Department _BCurrentDept, RelationalDatabase _DataBase)
        {
            #region 变量付值

            SystemCfg cfg1063 = new SystemCfg(1063);// 是否自动确费 Add By Zj 2012-07-02

            DataTable tb = mz_sf.Select_Wsfcf(0, Guid.Empty, ghxxid, 0, 0, Guid.Empty, 1, _DataBase);

            string ssql = "";

            //分组处方
            string[] GroupbyField           = { "HJID", "科室ID", "医生ID", "执行科室ID", "住院科室ID", "项目来源", "剂数", "划价日期", "hjy", "划价窗口" };
            string[] ComputeField           = { "金额", "hjmxid" };
            string[] CField                 = { "sum", "count" };
            TrasenFrame.Classes.TsSet xcset = new TrasenFrame.Classes.TsSet();
            xcset.TsDataTable = tb;
            DataTable tbcf = xcset.GroupTable(GroupbyField, ComputeField, CField, "1=1");
            if (tbcf.Rows.Count == 0)
            {
                MessageBox.Show("没有要收费的处方"); return;
            }

            Guid _hjid = Guid.Empty;
            int  _xmly = 0;

            //返回变量
            int    err_code = -1;
            string err_text = "";
            //时间
            string sDate = DateManager.ServerDateTimeByDBType(_DataBase).ToString();

            #endregion

            #region 处方审核
            try
            {
                //处方审核控制
                //医保病人处方需要审核
                //SystemCfg syscfg1 = new SystemCfg(1042);
                //if (syscfg1.Config == "1" && Convertor.IsNull(cmbyblx.SelectedValue, "0") != "0")
                //{
                //    DataRow[] rows = tb.Select(" 审核状态=0 or 审核状态=2");
                //    if (rows.Length > 0)
                //    {
                //        MessageBox.Show("该病人有处方未通过审核,不能收费", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //        return;
                //    }
                //}
                //所有病人的药品处方需要审核
                SystemCfg syscfg2 = new SystemCfg(1043);
                if (syscfg2.Config == "1")
                {
                    DataRow[] rows = tb.Select(" (审核状态=0 or 审核状态=2) and 项目来源=1");
                    if (rows.Length > 0)
                    {
                        MessageBox.Show("该病人有药品处方未通过审核,不能收费", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
            }
            catch (System.Exception err)
            {
                MessageBox.Show(err.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            #endregion

            #region 验证是否更改处方
            for (int i = 0; i <= tbcf.Rows.Count - 1; i++)
            {
                Guid    yz_hjid = new Guid(Convertor.IsNull(tbcf.Rows[i]["hjid"], Guid.Empty.ToString()));
                decimal yz_cfje = Math.Round(Convert.ToDecimal(Convertor.IsNull(tbcf.Rows[i]["金额"], "0")), 2);
                ssql = "select * from mz_hjb where hjid='" + yz_hjid + "'";
                DataTable yz_tb = _DataBase.GetDataTable(ssql);
                if (yz_tb.Rows.Count > 0)
                {
                    if (Convert.ToDecimal(yz_tb.Rows[0]["cfje"]) != yz_cfje)
                    {
                        MessageBox.Show("处方可能已更改,请重新刷新数据后重试!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (yz_tb.Rows[0]["bsfbz"].ToString() == "1")
                    {
                        MessageBox.Show("处方可能已收费,请重新刷新数据后重试!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("处方可能已删除,请刷新数据后重试!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                //add by zouchihua 2013-4-9 增加项目的判断 yzid
                ssql = "select * from mz_hjb_mx where hjid='" + yz_hjid + "' and  yzid='" + tbcf.Rows[i]["yzid"].ToString() + "'";
                DataTable hjmx = _DataBase.GetDataTable(ssql);
                if (hjmx.Rows.Count <= 0)
                {
                    MessageBox.Show("处方可能已经修改,请刷新数据后重试!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            #endregion

            try
            {
                sDate = DateManager.ServerDateTimeByDBType(_DataBase).ToString();

                _DataBase.BeginTransaction();

                #region 保处到处方表
                //decimal cfje = 0;
                for (int i = 0; i <= tbcf.Rows.Count - 1; i++)
                {
                    //插入处方头
                    Guid   _NewCfid = Guid.Empty;
                    string _mzh     = mzh;
                    _hjid = new Guid(Convertor.IsNull(tbcf.Rows[i]["hjid"], Guid.Empty.ToString()));
                    int _ksdm   = Convert.ToInt32(Convertor.IsNull(tbcf.Rows[i]["科室id"], "0"));
                    int _ysdm   = Convert.ToInt32(Convertor.IsNull(tbcf.Rows[i]["医生id"], "0"));
                    int _zxksdm = Convert.ToInt32(Convertor.IsNull(tbcf.Rows[i]["执行科室id"], "0"));
                    int _zyksdm = Convert.ToInt32(Convertor.IsNull(tbcf.Rows[i]["住院科室id"], "0"));
                    _xmly = Convert.ToInt32(Convertor.IsNull(tbcf.Rows[i]["项目来源"], "0"));
                    int     _js    = Convert.ToInt32(Convertor.IsNull(tbcf.Rows[i]["剂数"], "0"));
                    string  _cfrq  = tbcf.Rows[i]["划价日期"].ToString();
                    int     _hjyid = Convert.ToInt32(Convertor.IsNull(tbcf.Rows[i]["hjy"], "0"));
                    string  _hjyxm = Fun.SeekEmpName(_hjyid, _DataBase);
                    string  _hjck  = tbcf.Rows[i]["划价窗口"].ToString();
                    decimal _cfje  = Math.Round(Convert.ToDecimal(Convertor.IsNull(tbcf.Rows[i]["金额"], "0")), 2);


                    DataRow[] rows = tb.Select("HJID='" + _hjid + "' and 项目id>0");

                    long rowcount = Convert.ToInt32(tbcf.Rows[i]["HJMXID"]);
                    if (rowcount != rows.Length)
                    {
                        throw new Exception("分组处方时有" + rowcount + "行,插入处方时有" + rows.Length + "行.请检查处方状态或刷新处方再试");
                    }

                    if (rows.Length == 0)
                    {
                        throw new Exception("没有找到处方明细,请和管理员联系");
                    }
                    mz_cf.SaveCf(Guid.Empty, brxxid, ghxxid, _mzh, _hjck, _cfje, _cfrq, _hjyid, _hjyxm, _hjck, _hjid, _ksdm, Fun.SeekDeptName(_ksdm, _DataBase), _ysdm, Fun.SeekEmpName(_ysdm, _DataBase), _zyksdm, _zxksdm, Fun.SeekDeptName(_zxksdm, _DataBase), 0, 0, _xmly, 0, _js, TrasenFrame.Forms.FrmMdiMain.Jgbm, out _NewCfid, out err_code, out err_text, _DataBase);
                    if (_NewCfid == Guid.Empty || err_code != 0)
                    {
                        throw new Exception(err_text);
                    }

                    //插处方明细表

                    for (int j = 0; j <= rows.Length - 1; j++)
                    {
                        int _tcid = Convert.ToInt32(Convertor.IsNull(rows[j]["套餐id"], "0"));
                        //如果是套餐则分解保存
                        if (_tcid > 0)
                        {
                            #region 如果是套餐则分解保存

                            DataRow[] tcrow = tb.Select("HJID='" + _hjid + "' and  套餐id=" + _tcid + " ");
                            if (tcrow.Length == 0)
                            {
                                throw new Exception("查找套餐次数时出错,没有找到匹配的行");
                            }
                            _js = Convert.ToInt32(Convertor.IsNull(tcrow[0]["数量"], "0"));
                            DataTable Tabtc   = mz_sf.Select_Wsfcf(0, Guid.Empty, ghxxid, _tcid, _js, _hjid, _DataBase);
                            long      _tcyzid = Convert.ToInt64(Convertor.IsNull(rows[j]["yzid"], "0")); //Add By Zj 2012-08-14 根据yzid判断套餐
                            DataRow[] rows_tc = Tabtc.Select(" yzid=" + _tcyzid + " ");                  //" "
                            if (rows_tc.Length == 0)
                            {
                                throw new Exception("没有找到套餐的明细");
                            }
                            for (int xx = 0; xx <= rows_tc.Length - 1; xx++)
                            {
                                Guid    _NewCfmxid = Guid.Empty;
                                Guid    _hjmxid    = new Guid(Convertor.IsNull(rows_tc[xx]["hjmxid"], Guid.Empty.ToString()));
                                string  _pym       = Convertor.IsNull(rows_tc[xx]["拼音码"], "");
                                string  _bm        = Convertor.IsNull(rows_tc[xx]["编码"], "");
                                string  _pm        = Convertor.IsNull(rows_tc[xx]["项目名称"], "");
                                string  _spm       = Convertor.IsNull(rows_tc[xx]["商品名"], "");
                                string  _gg        = Convertor.IsNull(rows_tc[xx]["规格"], "");
                                string  _cj        = Convertor.IsNull(rows_tc[xx]["厂家"], "");
                                decimal _dj        = Convert.ToDecimal(Convertor.IsNull(rows_tc[xx]["单价"], "0"));
                                decimal _sl        = Convert.ToDecimal(Convertor.IsNull(rows_tc[xx]["数量"], "0"));
                                string  _dw        = Convertor.IsNull(rows_tc[xx]["单位"], "");
                                int     _ydwbl     = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["ydwbl"], "0"));
                                decimal _je        = Convert.ToDecimal(Convertor.IsNull(rows_tc[xx]["金额"], "0"));
                                string  _tjdxmdm   = Convertor.IsNull(rows_tc[xx]["统计大项目"], "");
                                long    _xmid      = Convert.ToInt64(Convertor.IsNull(rows_tc[xx]["项目id"], "0"));
                                //int _bpsyybz = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["皮试用药"], "0"));
                                int _bpsbz = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["皮试标志"], "0"));
                                //int _bmsbz = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["免试标志"], "0"));
                                decimal _yl     = Convert.ToDecimal(Convertor.IsNull(rows_tc[xx]["剂量"], "0"));
                                string  _yldw   = Convertor.IsNull(rows_tc[xx]["剂量单位"], "");
                                int     _yldwid = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["剂量单位id"], "0"));
                                int     _dwlx   = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["dwlx"], "0"));
                                int     _yfid   = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["用法id"], "0"));
                                string  _yfmc   = Convert.ToString(Convertor.IsNull(rows_tc[xx]["用法"], "0"));
                                int     _pcid   = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["频次id"], "0"));
                                string  _pcmc   = Convert.ToString(Convertor.IsNull(rows_tc[xx]["频次"], "0"));
                                decimal _ts     = Convert.ToDecimal(Convertor.IsNull(rows_tc[xx]["天数"], "0"));
                                string  _zt     = Convert.ToString(Convertor.IsNull(rows_tc[xx]["嘱托"], "0"));
                                int     _fzxh   = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["处方分组序号"], "0"));
                                int     _pxxh   = Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["排序序号"], "0"));
                                decimal _pfj    = Convert.ToDecimal(Convertor.IsNull(rows_tc[xx]["批发价"], "0"));
                                decimal _pfje   = Convert.ToDecimal(Convertor.IsNull(rows_tc[xx]["批发金额"], "0"));
                                if (_js != Convert.ToInt32(Convertor.IsNull(rows_tc[xx]["剂数"], "0")))
                                {
                                    throw new Exception("处方可能已修改,请重新刷新");
                                }
                                mz_cf.SaveCfmx(Guid.Empty, _NewCfid, _pym, _bm, _pm, _spm, _gg, _cj, _dj, _sl, _dw, _ydwbl, _js, _je, _tjdxmdm, _xmid, _hjmxid, _bm, 0, _bpsbz,
                                               Guid.Empty, _yl, _yldw, _yfmc, _pcid, _ts, _zt, _fzxh, _pxxh, Guid.Empty, _pfj, _pfje, _tcid, out _NewCfmxid, out err_code, out err_text, _DataBase);
                                if (_NewCfmxid == Guid.Empty || err_code != 0)
                                {
                                    throw new Exception(err_text);
                                }

                                #region 套餐确费
                                if (cfg1063.Config == "1" && Convert.ToInt32(Convertor.IsNull(rows[j]["执行科室ID"], "0")) != 0)
                                {
                                    ParameterEx[] parameters = new ParameterEx[10];
                                    parameters[0].Text  = "@CFID";
                                    parameters[0].Value = _NewCfid;
                                    parameters[1].Text  = "@CFMXID";
                                    parameters[1].Value = _NewCfmxid;
                                    parameters[2].Text  = "@TCID";
                                    parameters[2].Value = _tcid;


                                    parameters[3].Text  = "@BQRBZ";
                                    parameters[3].Value = 1;
                                    parameters[4].Text  = "@QRKS";
                                    parameters[4].Value = Convert.ToInt32(Convertor.IsNull(rows[j]["执行科室ID"], "0"));
                                    parameters[5].Text  = "@QRRQ";
                                    parameters[5].Value = sDate;

                                    parameters[6].Text  = "@QRDJY";
                                    parameters[6].Value = _BCurrentUser.EmployeeId;

                                    parameters[7].Text          = "@err_code";
                                    parameters[7].ParaDirection = ParameterDirection.Output;
                                    parameters[7].DataType      = System.Data.DbType.Int32;
                                    parameters[7].ParaSize      = 100;

                                    parameters[8].Text          = "@err_text";
                                    parameters[8].ParaDirection = ParameterDirection.Output;
                                    parameters[8].ParaSize      = 100;

                                    parameters[9].Text  = "@YQRKS";
                                    parameters[9].Value = 0;

                                    _DataBase.GetDataTable("SP_YJ_SAVE_QRJL_MZ", parameters, 60);
                                    err_code = Convert.ToInt32(parameters[7].Value);
                                    err_text = Convert.ToString(parameters[8].Value);
                                    if (err_code != 0)
                                    {
                                        throw new Exception(err_text);
                                    }
                                }
                                #endregion
                            }

                            #endregion
                        }
                        else
                        {
                            #region 非套餐
                            Guid    _NewCfmxid = Guid.Empty;
                            Guid    _hjmxid    = new Guid(Convertor.IsNull(rows[j]["hjmxid"], Guid.Empty.ToString()));
                            string  _pym       = Convertor.IsNull(rows[j]["拼音码"], "");
                            string  _bm        = Convertor.IsNull(rows[j]["编码"], "");
                            string  _pm        = Convertor.IsNull(rows[j]["项目名称"], "");
                            string  _spm       = Convertor.IsNull(rows[j]["商品名"], "");
                            string  _gg        = Convertor.IsNull(rows[j]["规格"], "");
                            string  _cj        = Convertor.IsNull(rows[j]["厂家"], "");
                            decimal _dj        = Convert.ToDecimal(Convertor.IsNull(rows[j]["单价"], "0"));
                            decimal _sl        = Convert.ToDecimal(Convertor.IsNull(rows[j]["数量"], "0"));
                            string  _dw        = Convertor.IsNull(rows[j]["单位"], "");
                            int     _ydwbl     = Convert.ToInt32(Convertor.IsNull(rows[j]["ydwbl"], "0"));
                            decimal _je        = Convert.ToDecimal(Convertor.IsNull(rows[j]["金额"], "0"));
                            string  _tjdxmdm   = Convertor.IsNull(rows[j]["统计大项目"], "");
                            long    _xmid      = Convert.ToInt64(Convertor.IsNull(rows[j]["项目id"], "0"));
                            //int _bpsyybz = Convert.ToInt32(Convertor.IsNull(rows[j]["皮试用药"], "0"));
                            int _bpsbz = Convert.ToInt32(Convertor.IsNull(rows[j]["皮试标志"], "0"));
                            //int _bmsbz = Convert.ToInt32(Convertor.IsNull(rows[j]["免试标志"], "0"));
                            decimal _yl       = Convert.ToDecimal(Convertor.IsNull(rows[j]["剂量"], "0"));
                            string  _yldw     = Convertor.IsNull(rows[j]["剂量单位"], "");
                            int     _yldwid   = Convert.ToInt32(Convertor.IsNull(rows[j]["剂量单位id"], "0"));
                            int     _dwlx     = Convert.ToInt32(Convertor.IsNull(rows[j]["dwlx"], "0"));
                            int     _yfid     = Convert.ToInt32(Convertor.IsNull(rows[j]["用法id"], "0"));
                            string  _yfmc     = Convert.ToString(Convertor.IsNull(rows[j]["用法"], "0"));
                            int     _pcid     = Convert.ToInt32(Convertor.IsNull(rows[j]["频次id"], "0"));
                            string  _pcmc     = Convert.ToString(Convertor.IsNull(rows[j]["频次"], "0"));
                            decimal _ts       = Convert.ToDecimal(Convertor.IsNull(rows[j]["天数"], "0"));
                            string  _zt       = Convert.ToString(Convertor.IsNull(rows[j]["嘱托"], ""));
                            int     _fzxh     = Convert.ToInt32(Convertor.IsNull(rows[j]["处方分组序号"], "0"));
                            int     _pxxh     = Convert.ToInt32(Convertor.IsNull(rows[j]["排序序号"], "0"));
                            decimal _pfj      = Convert.ToDecimal(Convertor.IsNull(rows[j]["批发价"], "0"));
                            decimal _pfje     = Convert.ToDecimal(Convertor.IsNull(rows[j]["批发金额"], "0"));
                            Guid    _pshjmxid = new Guid(Convertor.IsNull(rows[j]["pshjmxid"], Guid.Empty.ToString()));
                            mz_cf.SaveCfmx(Guid.Empty, _NewCfid, _pym, _bm, _pm, _spm, _gg, _cj, _dj, _sl, _dw, _ydwbl, _js, _je, _tjdxmdm, _xmid, _hjmxid, _bm, 0, _bpsbz,
                                           _pshjmxid, _yl, _yldw, _yfmc, _pcid, _ts, _zt, _fzxh, _pxxh, Guid.Empty, _pfj, _pfje, 0, out _NewCfmxid, out err_code, out err_text, _DataBase);
                            if (_NewCfmxid == Guid.Empty || err_code != 0)
                            {
                                throw new Exception(err_text);
                            }
                            //Add By Zj 2012-07-10
                            string updatejsdsql = "update mz_cfb_mx set jsd='" + Convert.ToString(Convertor.IsNull(rows[j]["JSD"], "0")) + "' where cfmxid='" + _NewCfmxid.ToString() + "' ";
                            _DataBase.DoCommand(updatejsdsql);
                            #region 非套餐确费
                            if (cfg1063.Config == "1" && Convert.ToInt32(Convertor.IsNull(rows[j]["执行科室ID"], "0")) != 0)
                            {
                                ParameterEx[] parameters = new ParameterEx[10];
                                parameters[0].Text  = "@CFID";
                                parameters[0].Value = _NewCfid;
                                parameters[1].Text  = "@CFMXID";
                                parameters[1].Value = _NewCfmxid;
                                parameters[2].Text  = "@TCID";
                                parameters[2].Value = 0;


                                parameters[3].Text  = "@BQRBZ";
                                parameters[3].Value = 1;
                                parameters[4].Text  = "@QRKS";
                                parameters[4].Value = Convert.ToInt32(Convertor.IsNull(rows[j]["执行科室ID"], "0"));
                                parameters[5].Text  = "@QRRQ";
                                parameters[5].Value = sDate;

                                parameters[6].Text  = "@QRDJY";
                                parameters[6].Value = _BCurrentUser.EmployeeId;

                                parameters[7].Text          = "@err_code";
                                parameters[7].ParaDirection = ParameterDirection.Output;
                                parameters[7].DataType      = System.Data.DbType.Int32;
                                parameters[7].ParaSize      = 100;

                                parameters[8].Text          = "@err_text";
                                parameters[8].ParaDirection = ParameterDirection.Output;
                                parameters[8].ParaSize      = 100;

                                parameters[9].Text  = "@YQRKS";
                                parameters[9].Value = 0;

                                _DataBase.GetDataTable("SP_YJ_SAVE_QRJL_MZ", parameters, 60);
                                err_code = Convert.ToInt32(parameters[7].Value);
                                err_text = Convert.ToString(parameters[8].Value);
                                if (err_code != 0)
                                {
                                    throw new Exception(err_text);
                                }
                            }
                            #endregion
                            #endregion 非套餐
                        }
                    }
                }
                #endregion

                _DataBase.CommitTransaction();
            }
            catch (System.Exception err)
            {
                _DataBase.RollbackTransaction();
                MessageBox.Show("保存数据出错!" + err.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Пример #7
0
        private void mnucwmb_Click(object sender, EventArgs e)
        {
            DataTable tb = (DataTable)dataGridView1.DataSource;

            try
            {
                if (dataGridView1.CurrentCell == null)
                {
                    return;
                }
                int nrow = dataGridView1.CurrentCell.RowIndex;
                if (tb.Rows.Count == 0)
                {
                    return;
                }
                Guid _hjID = new Guid(Convertor.IsNull(tb.Rows[nrow]["hjid"], Guid.Empty.ToString()));

                //分组处方
                string[] GroupbyField1           = { "HJID", "执行科室ID" };
                string[] ComputeField1           = { "金额" };
                string[] CField1                 = { "sum" };
                TrasenFrame.Classes.TsSet xcset1 = new TrasenFrame.Classes.TsSet();
                xcset1.TsDataTable = tb;
                DataTable tbcf1 = xcset1.GroupTable(GroupbyField1, ComputeField1, CField1, "hjid='" + _hjID + "' and 项目id>0");
                if (tbcf1.Rows.Count == 0)
                {
                    return;
                }

                string[] GroupbyField           = { "HJID", "执行科室ID", "项目来源", "剂数" };
                string[] ComputeField           = { "金额" };
                string[] CField                 = { "sum" };
                TrasenFrame.Classes.TsSet xcset = new TrasenFrame.Classes.TsSet();
                xcset.TsDataTable = tb;
                DataTable tbcf = xcset.GroupTable(GroupbyField, ComputeField, CField, "hjid='" + _hjID + "' and 项目id>0");
                if (tbcf.Rows.Count == 0)
                {
                    return;
                }

                if (tbcf1.Rows.Count != tbcf.Rows.Count)
                {
                    MessageBox.Show("请检查处方的数据是否正确,可能存在同一张处方有不同的执行科室或不同的医生或不同的开单科室的情况", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //返回变量
                int    _err_code = -1;
                string _err_text = "";
                //时间
                string _sDate = DateManager.ServerDateTimeByDBType(InstanceForm.BDatabase).ToString();

                Guid   _Mbid    = Guid.Empty;
                string _mbmc    = "";
                string _pym     = "";
                string _wbm     = "";
                string _bz      = "";
                int    _mbjb    = 2;
                int    _ksdm    = 0;
                int    _ysdm    = TrasenFrame.Forms.FrmMdiMain.CurrentUser.EmployeeId;
                int    _zxks    = Convert.ToInt32(Convertor.IsNull(tbcf.Rows[0]["执行科室ID"], "0"));
                string _djsj    = _sDate;
                int    _djy     = TrasenFrame.Forms.FrmMdiMain.CurrentUser.EmployeeId;
                string fid      = "";
                Guid   _NewMbid = Guid.Empty;
                int    _xmly    = Convert.ToInt32(tbcf.Rows[0]["项目来源"]);
                int    _js      = Convert.ToInt32(tbcf.Rows[0]["剂数"]);


                DlgInputBox Inputbox = new DlgInputBox("", "请输入模板名称", "保存模板");
                Inputbox.NumCtrl = false;
                Inputbox.ShowDialog();
                if (!DlgInputBox.DlgResult)
                {
                    return;
                }
                //Add By Zj 2012-03-15
                frmmbwh frmmbwh = new frmmbwh(_menuTag, _mbjb);
                frmmbwh.Text              = "选择模板所属分类.";
                frmmbwh.panel1.Visible    = false;
                frmmbwh.btnselect.Visible = true;
                frmmbwh.ShowDialog();
                if (frmmbwh.fid == "")
                {
                    return;
                }
                else
                {
                    fid = frmmbwh.fid;
                }
                _mbmc = DlgInputBox.DlgValue.ToString();
                if (_mbmc.Trim() == "")
                {
                    return;
                }


                InstanceForm.BDatabase.BeginTransaction();

                //查找当前处方
                DataRow[] rows = tb.Select("HJID='" + _hjID + "' and 执行科室ID=" + _zxks + "  and 项目id>0 ");

                jc_mb.SaveMb(_Mbid, TrasenFrame.Forms.FrmMdiMain.Jgbm, _mbmc, _pym, _wbm, _bz, _mbjb, _ksdm, _ysdm, _zxks, _djsj, _djy, fid, out _NewMbid, out _err_code, out _err_text, InstanceForm.BDatabase);
                if ((_NewMbid == Guid.Empty && _Mbid == Guid.Empty) || _err_code != 0)
                {
                    throw new Exception(_err_text);
                }

                if (rows == null)
                {
                    throw new Exception("没有找到行,请刷新数据");
                }
                if (rows.Length == 0 && _Mbid != Guid.Empty)
                {
                    throw new Exception("没有需要保存的行");
                }
                //插处方明细表
                for (int j = 0; j <= rows.Length - 1; j++)
                {
                    #region 保存明细
                    Guid    _NewMbmxid = Guid.Empty;
                    Guid    _mbmxid    = Guid.Empty;
                    string  _pm        = Convertor.IsNull(rows[j]["医嘱内容"], "");
                    decimal _dj        = Convert.ToDecimal(Convertor.IsNull(rows[j]["单价"], "0"));
                    decimal _sl        = Convert.ToDecimal(Convertor.IsNull(rows[j]["数量"], "0"));
                    decimal _je        = Convert.ToDecimal(Convertor.IsNull(rows[j]["金额"], "0"));
                    long    _xmid      = Convert.ToInt64(Convertor.IsNull(rows[j]["yzid"], "0"));
                    int     _bzby      = Convert.ToInt32(Convertor.IsNull(rows[j]["自备药"], "0"));
                    decimal _yl        = Convert.ToDecimal(Convertor.IsNull(rows[j]["剂量"], "0"));
                    string  _yldw      = Convertor.IsNull(rows[j]["剂量单位"], "");
                    int     _yldwid    = Convert.ToInt32(Convertor.IsNull(rows[j]["剂量单位id"], "0"));
                    int     _dwlx      = Convert.ToInt32(Convertor.IsNull(rows[j]["dwlx"], "0"));
                    int     _yfid      = Convert.ToInt32(Convertor.IsNull(rows[j]["用法id"], "0"));
                    int     _pcid      = Convert.ToInt32(Convertor.IsNull(rows[j]["频次id"], "0"));
                    decimal _ts        = Convert.ToDecimal(Convertor.IsNull(rows[j]["天数"], "0"));
                    string  _zt        = Convert.ToString(Convertor.IsNull(rows[j]["嘱托"], ""));
                    int     _fzxh      = Convert.ToInt32(Convertor.IsNull(rows[j]["处方分组序号"], "0"));
                    int     _pxxh      = Convert.ToInt32(Convertor.IsNull(rows[j]["排序序号"], "0"));
                    int     _cjid      = 0;
                    if (_xmly == 1)
                    {
                        _cjid = Convert.ToInt32(Convertor.IsNull(rows[j]["项目ID"], "0"));
                        Ypcj cj = new Ypcj(_cjid, InstanceForm.BDatabase);
                        _xmid = cj.GGID;
                    }
                    if ((_sl == 0 || _js == 0 || _je == 0) && _bzby == 0)
                    {
                        throw new Exception(_pm + " 没有数量或金额");
                    }
                    jc_mb.SaveMbmx(_mbmxid, _NewMbid, _xmid, _xmly, _yl, _yldw, _yldwid, _dwlx, _yfid, _pcid, _zt,
                                   _ts, _fzxh, _pxxh, _bzby, _cjid, _js, out _NewMbmxid, out _err_code, out _err_text, _hjID, _zxks, InstanceForm.BDatabase);
                    if ((_NewMbmxid == Guid.Empty && _mbmxid == Guid.Empty) || _err_code != 0)
                    {
                        throw new Exception(_err_text);
                    }

                    #endregion 保存明细
                }
                InstanceForm.BDatabase.CommitTransaction();

                MessageBox.Show("保存成功");
            }
            catch (System.Exception err)
            {
                InstanceForm.BDatabase.RollbackTransaction();
                MessageBox.Show(err.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Пример #8
0
        private void btnsfyhz_Click(object sender, EventArgs e)
        {
            if (dataGridView2.DataSource == null)
            {
                return;
            }
            DataTable tb = (DataTable)dataGridView2.DataSource;

            string[] GroupbyField1           = { "医保类型", "结算员" };
            string[] ComputeField1           = { "结算金额", "帐户支付", "统筹支付", "其它支付", "现金支付" };
            string[] CField1                 = { "sum", "sum", "sum", "sum", "sum" };
            TrasenFrame.Classes.TsSet xcset1 = new TrasenFrame.Classes.TsSet();
            xcset1.TsDataTable = tb;
            DataTable tbcf1 = xcset1.GroupTable(GroupbyField1, ComputeField1, CField1, "");

            if (tbcf1.Rows.Count == 0)
            {
                return;
            }
            tbcf1.Columns.Remove("发票号");
            tbcf1.Columns.Remove("姓名");
            tbcf1.Columns.Remove("结算时间");
            try
            {
                DataTable tbmx = tbcf1;

                ts_mz_report.DataSet1 Dset = new ts_mz_report.DataSet1();

                DataRow myrow = Dset.收费项目.NewRow();
                for (int i = 0; i <= tbmx.Columns.Count - 1; i++)
                {
                    int    x  = i + 1;
                    string nm = "T" + x.ToString();
                    myrow[nm] = tbmx.Columns[i].ColumnName.Trim();
                }
                Dset.收费项目.Rows.Add(myrow);

                for (int nrow = 0; nrow <= tbmx.Rows.Count - 1; nrow++)
                {
                    DataRow myrow1 = Dset.收费项目金额.NewRow();
                    for (int i = 0; i <= tbmx.Columns.Count - 1; i++)
                    {
                        int    x  = i + 1;
                        string nm = "JE" + x.ToString();
                        myrow1[nm] = tbmx.Rows[nrow][tbmx.Columns[i].ColumnName].ToString();
                    }
                    Dset.收费项目金额.Rows.Add(myrow1);
                }


                ParameterEx[] parameters = new ParameterEx[2];

                parameters[0].Text  = "医院名称";
                parameters[0].Value = TrasenFrame.Classes.Constant.HospitalName;

                parameters[1].Text  = "条件";
                parameters[1].Value = "收费日期:" + dtp1.Value.ToString("yyyy-MM-dd HH:mm:ss") + " 到 " + dtp2.Value.ToString("yyyy-MM-dd HH:mm:ss");

                TrasenFrame.Forms.FrmReportView f;
                f = new TrasenFrame.Forms.FrmReportView(Dset, Constant.ApplicationDirectory + "\\Report\\MZ_医保结算统计(按收费员汇总).rpt", parameters);
                if (f.LoadReportSuccess)
                {
                    f.Show();
                }
                else
                {
                    f.Dispose();
                }
            }
            catch (System.Exception err)
            {
                MessageBox.Show(err.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #9
0
        private void AddPresc(DataTable tb)
        {
            try
            {
                decimal   sumje = 0;
                DataTable tbmx  = tb.Clone();

                string[] GroupbyField           = { "HJID" };
                string[] ComputeField           = { "金额" };
                string[] CField                 = { "sum" };
                TrasenFrame.Classes.TsSet xcset = new TrasenFrame.Classes.TsSet();
                xcset.TsDataTable = tb;
                DataTable tbcf = xcset.GroupTable(GroupbyField, ComputeField, CField, "序号<>'小计' and (自备药<>1) ");
                bool      b_ks = false;
                for (int i = 0; i <= tbcf.Rows.Count - 1; i++)
                {
                    DataRow[] rows = tb.Select("HJID='" + tbcf.Rows[i]["hjid"].ToString().Trim() + "'");
                    for (int j = 0; j <= rows.Length - 1; j++)
                    {
                        DataRow row = tb.NewRow();
                        row         = rows[j];
                        row["序号"]   = j + 1;
                        row["开嘱时间"] = ' ' + Convert.ToDateTime(rows[j]["划价日期"]).ToString("MM-dd HH:mm");
                        if (row["自备药"].ToString() == "1")
                        {
                            row["医嘱内容"] = row["医嘱内容"] + " 【自备】";
                        }
                        if (row["处方分组序号"].ToString() == "1")
                        {
                            b_ks = true; row["医嘱内容"] = "┌" + row["医嘱内容"].ToString();
                        }
                        if (row["处方分组序号"].ToString() == "2" && b_ks == true)
                        {
                            row["医嘱内容"] = "│" + row["医嘱内容"].ToString();
                        }
                        if (row["处方分组序号"].ToString() == "-1" && b_ks == true)
                        {
                            b_ks = false; row["医嘱内容"] = "└" + row["医嘱内容"].ToString();
                        }
                        if (row["皮试标志"].ToString() == "0" && row["项目来源"].ToString() == "1")
                        {
                            row["医嘱内容"] = row["医嘱内容"] + " 【皮试】";
                        }
                        if (row["皮试标志"].ToString() == "1")
                        {
                            row["医嘱内容"] = row["医嘱内容"] + " 【-】";
                        }
                        if (row["皮试标志"].ToString() == "2")
                        {
                            row["医嘱内容"] = row["医嘱内容"] + " 【+】";
                        }
                        if (row["皮试标志"].ToString() == "3")
                        {
                            row["医嘱内容"] = row["医嘱内容"] + " 【免试】";
                        }
                        if (row["皮试标志"].ToString() == "9")
                        {
                            row["医嘱内容"] = row["医嘱内容"] + " 【皮试液】";
                        }
                        row["选择"] = false;
                        tbmx.ImportRow(row);
                    }
                    DataRow sumrow = tbmx.NewRow();
                    sumrow["序号"] = "小计";
                    sumrow["收费"] = false;
                    decimal je = Math.Round(Convert.ToDecimal(tbcf.Rows[i]["金额"]), 2);
                    sumrow["金额"]   = je.ToString("0.00");
                    sumje          = sumje + je;
                    sumrow["hjid"] = tbcf.Rows[i]["hjid"];
                    sumrow["分方状态"] = "";// tbcf.Rows[i]["分方状态"];
                    tbmx.Rows.Add(sumrow);
                }
                tbmx.AcceptChanges();
                dataGridView1.DataSource  = tbmx;
                dataGridView1.CurrentCell = null;

                if (tbcf.Rows.Count > 0)
                {
                    lblcfhj.Text = sumje.ToString();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("加载处方信息有误:" + ex.Message);
            }
        }
Пример #10
0
        private void frmJmcx_Load(object sender, System.EventArgs e)
        {
            string[] GrdMappingName = { "Inpatient_ID", "Baby_ID", "床号", "住院号", "姓名", "日期", "时间", "医生", "医嘱内容", "采血费次数", "采血管次数", "dept_br", "dept_id" };
            int[]    GrdWidth       = { 0, 0, 4, 9, 8, 6, 6, 8, 42, 10, 10, 0, 0 };
            int[]    Alignment      = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            int[]    ReadOnly       = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 };
            //不现实医嘱内容
            if (cfg7161.Config.Trim() == "1")
            {
                GrdWidth[8] = 0;
            }
            myFunc.InitGrid(GrdMappingName, GrdWidth, Alignment, ReadOnly, this.myDataGrid1);
            //add by zouchihua 2013-8-27
            if (cfg7161.Config.Trim() == "0")
            {
                int i = 0;
                for (i = 0; i < inTb.Rows.Count; i++)
                {
                    if (i == 0)
                    {
                        inTb.Rows[i]["采血费次数"] = "1";
                        inTb.Rows[i]["采血管次数"] = "1";
                    }
                    if (!(i != 0 && inTb.Rows[i]["姓名"].ToString().Trim() == inTb.Rows[i - 1]["姓名"].ToString().Trim()))
                    {
                        inTb.Rows[i]["采血费次数"] = "1";
                        inTb.Rows[i]["采血管次数"] = "1";
                    }
                }
                myDataGrid1.DataSource = inTb;
            }
            else
            {
                //根据条码分组产生血管
                DataTable tbBfz = new DataTable();
                try
                {
                    tbBfz = FrmMdiMain.Database.GetDataTable("select * from JC_JYBBFLMX_bfl ");
                }
                catch { }
                string tj = "  (";
                for (int i = 0; i < _orderlist.Count; i++)
                {
                    if (i != _orderlist.Count - 1)
                    {
                        tj += "'" + _orderlist[i].ToString() + "',";
                    }
                    else
                    {
                        tj += "'" + _orderlist[i].ToString() + "' )";
                    }
                }
                string sql = "select a.ORDER_ID ,CONVERT(varchar,a.ORDER_BDATE,23) sqrq,a.INPATIENT_ID,a.baby_id ,RTRIM(B.ORDER_EXTENSION) 标本类型,B.FJSM  说明,cast(ISNULL( cast(ISNULL(d.FLID,-B.ID) as  varchar(36) ),a.ORDER_ID ) as varchar(36)) 分组 ,"
                             + "  case when B.ORDER_CONTEXT not like '%急%' OR b.ORDER_CONTEXT IS null then   case when a.MEMO like '%★%' then SUBSTRING(a.MEMO,0,CHARINDEX('★',a.memo)) else '' end  else   "
                             + "  (case when a.MEMO like '%★%' then SUBSTRING(a.MEMO,0,CHARINDEX('★',a.memo)) else '' end)+'[急]' end  as 附加说明, "
                             + " b.ORDER_CONTEXT,a.HOITEM_ID YZXMID from ZY_ORDERRECORD a left join ZY_JY_PRINT b on a.ORDER_ID=b.ORDER_ID   "
                             + "  left join JC_ASSAY c on a.HOITEM_ID=c.YZID left join JC_JYBBFLMX d on a.HOITEM_ID=d.YZXMID ";
                sql += " where a.order_id in " + tj;
                DataTable tb = InstanceForm.BDatabase.GetDataTable(sql);
                #region//add by zouchihua 2013-6-27 不能打在一起
                try
                {
                    if (tbBfz.Rows.Count > 0)
                    {
                        for (int i = 0; i < tb.Rows.Count; i++)
                        {
                            //如果项目id在tbBfz里面
                            DataRow[] row = tbBfz.Select("YZXMID=" + tb.Rows[i]["YZXMID"].ToString() + "");
                            if (row.Length > 0)
                            {
                                for (int j = i; j < tb.Rows.Count; j++)
                                {
                                    if (i != j &&
                                        tb.Rows[i]["INPATIENT_ID"].ToString().Trim() == tb.Rows[j]["INPATIENT_ID"].ToString().Trim() &&
                                        tb.Rows[i]["分组"].ToString() == tb.Rows[j]["分组"].ToString()
                                        )
                                    {
                                        for (int k = 0; k < row.Length; k++)
                                        {
                                            if (tbBfz.Select("bflid=" + row[k]["bflid"] + "  and  yzxmid=" + tb.Rows[j]["YZXMID"].ToString()).Length > 0)//如果两个都在分类中 说明不能打在一起
                                            //把相同的组号改为不同
                                            {
                                                tb.Rows[j]["分组"] = "-1" + tb.Rows[j]["ORDER_ID"].ToString();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex) { }
                #endregion
                #region
                string[] GroupbyField           = { "inpatient_id", "baby_id", "分组", "附加说明", "sqrq", "标本类型" };
                string[] ComputeField           = { };
                string[] CField                 = { };
                TrasenFrame.Classes.TsSet tsset = new TrasenFrame.Classes.TsSet();
                tsset.TsDataTable = tb;
                DataTable patTb   = tsset.GroupTable(GroupbyField, ComputeField, CField, "");
                ArrayList argroup = new ArrayList();
                for (int k = 0; k < patTb.Rows.Count; k++)
                {
                    DataRow[] row = tb.Select(" inpatient_id='" + patTb.Rows[k]["inpatient_id"].ToString() + "' and baby_id=" + patTb.Rows[k]["baby_id"].ToString() + " and 分组='" + patTb.Rows[k]["分组"].ToString() +
                                              "' and 附加说明='" + patTb.Rows[k]["附加说明"].ToString() + "'  and sqrq='" + patTb.Rows[k]["sqrq"].ToString() + "'  and  标本类型='" + patTb.Rows[k]["标本类型"].ToString() + "'");
                    for (int i = 0; i < row.Length; i++)
                    {
                        row[i]["分组"] = 90000 + k + 1;
                    }
                }

                for (int i = 0; i < tb.Rows.Count; i++)
                {
                    for (int j = i; j < tb.Rows.Count; j++)
                    {
                        if (i != j &&
                            tb.Rows[i]["INPATIENT_ID"].ToString().Trim() == tb.Rows[j]["INPATIENT_ID"].ToString().Trim() &&
                            tb.Rows[i]["分组"].ToString() == tb.Rows[j]["分组"].ToString()
                            &&
                            tb.Rows[i]["YZXMID"].ToString() == tb.Rows[j]["YZXMID"].ToString()
                            // &&(tb.Rows[j]["附加说明"].ToString().Trim()!=""&&  tb.Rows[i]["附加说明"].ToString().Trim() != tb.Rows[j]["附加说明"].ToString().Trim() )  //附加说明不一样要分开 Mofiby by zouchihua 2013-7-3
                            )
                        {
                            //把相同的组号改为不同
                            tb.Rows[j]["分组"] = "-1" + tb.Rows[j]["ORDER_ID"].ToString();
                        }
                    }
                }
                string[] GroupbyField1           = { "inpatient_id", "baby_id", "分组", };
                string[] ComputeField1           = { };
                string[] CField1                 = { };
                TrasenFrame.Classes.TsSet tsset1 = new TrasenFrame.Classes.TsSet();
                tsset1.TsDataTable = tb;
                DataTable patTbtemp      = tsset.GroupTable(GroupbyField1, ComputeField1, CField1, "");
                DataTable newinTb        = inTb.Clone();
                string    oldinpatientid = "";
                string    oldbabyid      = "";
                //每个人应该只有一条医嘱
                for (int j = 0; j < patTbtemp.Rows.Count; j++)
                {
                    if (oldbabyid == "")
                    {
                        DataRow[] row = patTbtemp.Select(" inpatient_id='" + patTbtemp.Rows[j]["inpatient_id"].ToString() + "' and baby_id=" + patTbtemp.Rows[j]["baby_id"].ToString() + " ");
                        inTb.Rows[j]["采血费次数"] = "1";
                        inTb.Rows[j]["采血管次数"] = row.Length.ToString();
                        oldbabyid             = patTbtemp.Rows[j]["baby_id"].ToString();
                        oldinpatientid        = patTbtemp.Rows[j]["inpatient_id"].ToString();
                        newinTb.Rows.Add(inTb.Rows[j].ItemArray);
                    }
                    else
                    if (oldinpatientid == patTbtemp.Rows[j]["inpatient_id"].ToString() && oldbabyid == patTbtemp.Rows[j]["baby_id"].ToString())
                    {
                        continue;
                    }
                    else
                    {
                        DataRow[] row = patTbtemp.Select(" inpatient_id='" + patTbtemp.Rows[j]["inpatient_id"].ToString() + "' and baby_id=" + patTbtemp.Rows[j]["baby_id"].ToString() + " ");
                        inTb.Rows[j]["采血费次数"] = "1";
                        inTb.Rows[j]["采血管次数"] = row.Length.ToString();
                        oldbabyid             = patTbtemp.Rows[j]["baby_id"].ToString();
                        oldinpatientid        = patTbtemp.Rows[j]["inpatient_id"].ToString();
                        newinTb.Rows.Add(inTb.Rows[j].ItemArray);
                    }
                }
                #endregion
                myDataGrid1.DataSource = newinTb;
            }

            DataGridCell myCel = new DataGridCell(0, 9);
            myDataGrid1.CurrentCell = myCel;
        }