Exemplo n.º 1
0
        public static int SeekGhdwByKcid(string yppch, int deptid, RelationalDatabase db, int cjid)
        {
            bool      byk    = Yp.是否药库(deptid, db);
            int       ghdwid = 0;
            string    ssql   = "";
            DataTable tb;

            if (byk)
            {
                ssql = string.Format(" select wldw from yk_dj where id = ( select djid from yk_djmx where id = ( select rkdjmxid from yk_kcph where (rkdjmxid is not null and rkdjmxid <> dbo.fun_getemptyguid()) and yppch='{0}' and cjid={1}) )", yppch, cjid);
                tb   = db.GetDataTable(ssql);
                if (tb.Rows.Count <= 0)
                {
                    ghdwid = 0;
                }
                else
                {
                    ghdwid = Convert.ToInt32(tb.Rows[0][0]);
                }
            }
            else
            {
                ghdwid = 0;
            }
            return(ghdwid);
        }
Exemplo n.º 2
0
        private void butsc_Click(object sender, System.EventArgs e)
        {
            if (Yp.是否药库(InstanceForm.BCurrentDept.DeptId, InstanceForm.BDatabase) == true)
            {
                MessageBox.Show("您现在进入的是药房系统,请核实您当前登陆的科室是否正确", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            #region   发药明细表的数据
            string stext = this.Text.Trim();
            //上传发药明细表的数据
            //this.Cursor =Cursors.WaitCursor;
            this.Text = "正在上传处方发药明细.....";

            try
            {
                this.Cursor = PubStaticFun.WaitCursor();
                int    err_code = -1;
                string err_text = "";

                InstanceForm.BDatabase.BeginTransaction();

                string        sDate      = DateManager.ServerDateTimeByDBType(InstanceForm.BDatabase).ToString();
                ParameterEx[] parameters = new ParameterEx[8];
                parameters[0].Text  = "@djrq";
                parameters[0].Value = Convert.ToDateTime(sDate).ToShortDateString();

                parameters[1].Text  = "@djsj";
                parameters[1].Value = Convert.ToDateTime(sDate).ToLongTimeString();

                parameters[2].Text  = "@djy";
                parameters[2].Value = InstanceForm.BCurrentUser.EmployeeId;

                parameters[3].Text  = "@deptid";
                parameters[3].Value = InstanceForm.BCurrentDept.DeptId;

                parameters[4].Text  = "@endrq";
                parameters[4].Value = dtpendrq.Value.ToShortDateString();

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

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

                parameters[7].Text  = "@jgbm";
                parameters[7].Value = InstanceForm._menuTag.Jgbm;


                InstanceForm.BDatabase.DoCommand("SP_YF_fymx_dj", parameters, 30);
                err_code = Convert.ToInt32(parameters[5].Value);
                err_text = Convert.ToString(parameters[6].Value);

                //更新处方上传日期
                string rq   = this.dtpendrq.Value.ToShortDateString() + " " + System.DateTime.Now.ToLongTimeString();
                string ssql = "update yp_yjks set cfscrq='" + rq + "' where deptid=" + InstanceForm.BCurrentDept.DeptId + "";
                InstanceForm.BDatabase.DoCommand(ssql);


                InstanceForm.BDatabase.CommitTransaction();

                this.lblscscrq.Text = rq.Trim();
                this.Text           = "上传处方记录成功";
                //MessageBox.Show("上传处方记录成功");
            }
            catch (System.Exception err)
            {
                InstanceForm.BDatabase.RollbackTransaction();
                MessageBox.Show("在上传发药明细时发生错误" + err.Message);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }
            #endregion
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            if (Yp.是否药库(InstanceForm.BCurrentDept.DeptId, InstanceForm.BDatabase) == true)
            {
                MessageBox.Show("您现在进入的是药房系统,请核实您当前登陆的科室是否正确", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            #region 先上传发药明细
            butsc_Click(sender, e);
            #endregion

            string stext = "";
            if (_menuTag.Function_Name.Trim() != "Fun_ts_yf_unymjz")
            {
                #region 系统对账


                //系统对账
                this.Text = "正在进行系统对账.....";
                try
                {
                    this.Cursor = PubStaticFun.WaitCursor();

                    ParameterEx[] parameters = new ParameterEx[2];
                    parameters[0].Text  = "@jsrq";
                    parameters[1].Text  = "@deptid";
                    parameters[0].Value = dtp1.Value.ToString();// dtp1.Value.ToShortDateString();
                    parameters[1].Value = InstanceForm.BCurrentDept.DeptId;
                    DataTable tb = InstanceForm.BDatabase.GetDataTable("SP_YF_XTDZ", parameters, 60);
                    tb.TableName = "myTb";

                    if (tb.Rows.Count > 0)
                    {
                        this.Close();
                        Frmxtdzmx f = new Frmxtdzmx(_menuTag, _chineseName, _mdiParent);
                        f.MdiParent = _mdiParent;
                        f.Show();
                        f.FillData(tb);
                        return;
                    }

                    if (_menuTag.Function_Name.Trim() == "Fun_ts_yf_xtdz")
                    {
                        MessageBox.Show("系统对帐完成");
                        this.Text = stext;
                        this.Close();
                        return;
                    }
                }
                catch (System.Exception err)
                {
                    MessageBox.Show("出错" + err.Message);
                    return;
                }
                finally
                {
                    this.Cursor = Cursors.Arrow;
                }

                #endregion
            }

            #region 取消上次月结

            //取消上次月结
            if (_menuTag.Function_Name.Trim() == "Fun_ts_yf_unymjz" &&
                MessageBox.Show("您确定要取消 [" + txtbz.Text + "] 这次月结吗 ?", "询问窗", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                this.Cursor = PubStaticFun.WaitCursor();
                this.Text   = "正在取消上次月结.....";

                try
                {
                    int    err_code = -1;
                    string err_text = "";

                    InstanceForm.BDatabase.BeginTransaction();

                    ParameterEx[] parameters = new ParameterEx[5];
                    parameters[0].Text  = "@deptid";
                    parameters[0].Value = InstanceForm.BCurrentDept.DeptId;

                    parameters[1].Text  = "@djsj";
                    parameters[1].Value = DateManager.ServerDateTimeByDBType(InstanceForm.BDatabase).ToString();

                    parameters[2].Text  = "@djy";
                    parameters[2].Value = InstanceForm.BCurrentUser.EmployeeId;

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

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


                    InstanceForm.BDatabase.DoCommand("sp_Yf_unymjc", parameters, 60);
                    err_code = Convert.ToInt32(parameters[3].Value);
                    err_text = Convert.ToString(parameters[4].Value);

                    if (err_code != 0)
                    {
                        throw new Exception(err_text);
                    }
                    InstanceForm.BDatabase.CommitTransaction();

                    this.Text = stext;

                    #region 日志记录
                    string str_old = "";
                    str_old = InstanceForm.BCurrentUser.Name + "取消月结.上次月结时间是" + dtp1.Value.ToString() + " 到:" + dtp2.Value.ToString();
                    SystemLog systemLog = new SystemLog(-1, InstanceForm.BCurrentDept.DeptId, InstanceForm.BCurrentUser.EmployeeId, "取消月结", str_old, DateManager.ServerDateTimeByDBType(InstanceForm.BDatabase), 0, "主机名:" + System.Environment.MachineName, 8);
                    systemLog.Save();
                    systemLog = null;
                    #endregion

                    MessageBox.Show(err_text);
                    this.Close();
                    return;
                }
                catch (System.Exception err)
                {
                    InstanceForm.BDatabase.RollbackTransaction();
                    this.butok.Enabled = true;
                    MessageBox.Show(err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    this.Cursor = Cursors.Arrow;
                }
            }
            #endregion

            #region 月未结账

            if (_menuTag.Function_Name.Trim() != "Fun_ts_yf_ymjz")
            {
                return;
            }


            //月未结帐
            this.Text = "正在进行月未结帐.....";

            try
            {
                if (dtp2.Value < dtp1.Value)
                {
                    MessageBox.Show("月结止日期不能小于开始日期", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (dtp2.Value > DateManager.ServerDateTimeByDBType(InstanceForm.BDatabase))
                {
                    MessageBox.Show("月结止日期不能大于系统当前时间", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                butok.Enabled = false;
                this.Cursor   = PubStaticFun.WaitCursor();
                int    err_code = -1;
                string err_text = "";

                InstanceForm.BDatabase.BeginTransaction();

                ParameterEx[] parameters = new ParameterEx[9];
                parameters[0].Text  = "@year";
                parameters[0].Value = _year;

                parameters[1].Text  = "@month";
                parameters[1].Value = _month;

                parameters[2].Text  = "@deptid";
                parameters[2].Value = InstanceForm.BCurrentDept.DeptId;

                parameters[3].Text  = "@ksrq";
                parameters[3].Value = dtp1.Value.ToString();//dtp1.Value.ToShortDateString();;

                parameters[4].Text  = "@jsrq";
                parameters[4].Value = dtp2.Value.ToString(); //dtp2.Value.ToShortDateString();

                parameters[5].Text  = "@djsj";
                parameters[5].Value = DateManager.ServerDateTimeByDBType(InstanceForm.BDatabase).ToString();

                parameters[6].Text  = "@djy";
                parameters[6].Value = InstanceForm.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;


                InstanceForm.BDatabase.DoCommand("sp_YF_ymjc", parameters, 60);
                err_code = Convert.ToInt32(parameters[7].Value);
                err_text = Convert.ToString(parameters[8].Value);


                if (err_code != 0)
                {
                    throw new System.Exception(err_text);
                }

                InstanceForm.BDatabase.CommitTransaction();

                YMJC   ymjc    = new YMJC(InstanceForm.BDatabase);
                string message = "";
                bool   bOk     = ymjc.GenerateDetailData(InstanceForm.BCurrentDept.DeptId, _year, _month, out message);
                if (!bOk)
                {
                    this.Text = stext;
                    MessageBox.Show("月结成功,但生成中间表数据失败,请联系管理员处理", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    butok.Enabled = true;
                    this.Close();
                    return;
                }

                this.Text = stext;
                MessageBox.Show(err_text);
                butok.Enabled = true;
                this.Close();
            }
            catch (System.Exception err)
            {
                InstanceForm.BDatabase.RollbackTransaction();
                this.butok.Enabled = true;
                MessageBox.Show(err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }
            #endregion
        }
Exemplo n.º 4
0
        private void buttj_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(cmbyear.Text) || string.IsNullOrEmpty(cmbmonth.Text))
            {
                MessageBox.Show("请输入年份月份");
                return;
            }
            try
            {
                textBox1.Focus();
                this.Cursor        = PubStaticFun.WaitCursor();
                this.buttj.Enabled = false;

                bool yk = Yp.是否药库(Convert.ToInt32(Convertor.IsNull(cmbyjks.SelectedValue, "0")), InstanceForm.BDatabase);

                ParameterEx[] parameters = new ParameterEx[6];
                parameters[0].Text          = "@yk";
                parameters[0].Value         = Convert.ToInt32(yk);
                parameters[1].Text          = "@jhjetj";
                parameters[1].Value         = radioButton2.Checked ? 0 : 1;
                parameters[2].Text          = "@year";
                parameters[2].Value         = Convert.ToInt32(cmbyear.Text.ToString());
                parameters[3].Text          = "@month";
                parameters[3].Value         = Convert.ToInt32(cmbmonth.Text.ToString());
                parameters[4].Text          = "@ERR_CODE";
                parameters[4].ParaDirection = ParameterDirection.Output;
                parameters[4].DataType      = System.Data.DbType.Int32;
                parameters[4].ParaSize      = 100;
                parameters[5].Text          = "@ERR_TEXT";
                parameters[5].ParaDirection = ParameterDirection.Output;
                parameters[5].DataType      = System.Data.DbType.Int32;
                parameters[5].ParaSize      = 100;
                DataTable tb = InstanceForm.BDatabase.GetDataTable("sp_yp_tj_cktj_mzzy", parameters, 30);

                if (cmbyjks.Text != "全部")
                {
                    object    deptid     = cmbyjks.SelectedValue;
                    string    sql        = string.Format(" select fzmc  from yp_yjks where DEPTID ={0}", deptid);
                    DataTable dt         = InstanceForm.BDatabase.GetDataTable(sql);
                    string    parentDept = dt != null && dt.Rows.Count > 0 ? dt.Rows[0][0].ToString() : "";
                    if (string.IsNullOrEmpty(parentDept))
                    {
                        return;
                    }
                    DataRow[] retRows   = tb.Select(string.Format(" 药剂科室 = '{0}'", parentDept));
                    DataTable currTable = tb.Clone();
                    currTable.TableName = "Tb";
                    if (retRows != null && retRows.Length > 0)
                    {
                        foreach (DataRow tmpRow in retRows)
                        {
                            currTable.Rows.Add(tmpRow.ItemArray);
                        }
                    }
                    dataGridView1.DataSource = currTable;
                }
                else
                {
                    tb.TableName             = "Tb";
                    dataGridView1.DataSource = tb;
                }
                this.buttj.Enabled = true;
            }
            catch (System.Exception err)
            {
                this.buttj.Enabled = true;
                MessageBox.Show(err.Message);
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }
        }