예제 #1
0
파일: FrmDeptMed.cs 프로젝트: Wooyme/HIS-1
        private void butadd_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (Convert.ToInt32(Convertor.IsNull(lblypmc.Tag, "0")) == 0)
                {
                    MessageBox.Show("没有选择药品");
                    return;
                }

                if (Convertor.IsNumeric(Convertor.IsNull(lblypmc.Tag, "0")) == false)
                {
                    MessageBox.Show("基数请输入数字");
                    return;
                }

                DataTable tb        = (DataTable)this.myDataGrid1.DataSource;
                DataRow   row       = tb.NewRow();
                int       _ggid     = Convert.ToInt32(Convertor.IsNull(lblypmc.Tag, "0"));
                DataRow[] selectrow = tb.Select("ggid='" + _ggid.ToString() + "'");
                if (selectrow.Length > 0)
                {
                    MessageBox.Show("当前药品已在列表添加了");
                    return;
                }

                Ypgg ydgg = new Ypgg(_ggid, InstanceForm.BDatabase);
                row["序号"]  = tb.Rows.Count + 1;
                row["品名"]  = ydgg.YPPM;
                row["商品名"] = ydgg.YPSPM;
                row["规格"]  = ydgg.YPGG;
                //row["零售价"]=ydcj.LSJ;
                row["基数"] = Convertor.IsNull(txtjs.Text, "0");
                row["单位"] = Yp.SeekYpdw(ydgg.YPDW, InstanceForm.BDatabase);
                //row["货号"]=ydcj.SHH;
                row["ggid"] = ydgg.GGID;
                row["启用日期"] = this.dtpqyrq.Value.ToShortDateString();
                tb.Rows.Add(row);
                lblypmc.Text = "";
                lblypmc.Tag  = "0";
                lblgg.Text   = "";
                //lblcj.Text="";
                lbldw.Text = "";
                //lbllsj.Text="";
                //lblhh.Text="";
                txtypdm.Text = "";
                txtjs.Text   = "";
                txtypdm.Focus();
            }
            catch (System.Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }
예제 #2
0
파일: FrmDeptMed.cs 프로젝트: Wooyme/HIS-1
 //初始药品
 private void csyp(int ggid, int cjid)
 {
     try
     {
         Ypgg ydgg = new Ypgg(ggid, InstanceForm.BDatabase);
         this.lblypmc.Tag   = ydgg.GGID.ToString();
         this.lblypmc.Text  = ydgg.YPPM;
         this.lblypspm.Text = ydgg.YPSPM;
         this.lblgg.Text    = ydgg.YPGG;
         //this.lblcj.Text=ydcj.S_SCCJ;
         //this.lblhh.Text=ydcj.SHH;
         //this.lbllsj.Text=ydcj.LSJ.ToString() ;
         this.lbldw.Text = Yp.SeekYpdw(ydgg.YPDW, InstanceForm.BDatabase);
     }
     catch (System.Exception err)
     {
         MessageBox.Show("发生错误" + err.Message);
     }
 }
예제 #3
0
파일: Frmhb.cs 프로젝트: Wooyme/HIS-1
        private void butok_hb_Click(object sender, System.EventArgs e)
        {
            DataTable tb    = (DataTable)this.myDataGrid1.DataSource;
            DataTable tab   = (DataTable)this.myDataGrid2.DataSource;
            int       nrow1 = this.myDataGrid1.CurrentCell.RowNumber;
            int       nrow2 = this.myDataGrid2.CurrentCell.RowNumber;

            if (nrow1 > tb.Rows.Count - 1)
            {
                return;
            }
            if (nrow2 > tab.Rows.Count - 1)
            {
                return;
            }

            if (MessageBox.Show("您确定要将上面的厂家替换成下面的规格吗 ?", "询问窗", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
            {
                return;
            }

            //要替换成的规格ID
            int _gg_ggid = Convert.ToInt32(tab.Rows[nrow2]["ggid"]);


            try
            {
                Ypgg gg = new Ypgg(_gg_ggid, InstanceForm.BDatabase);
                if (gg.GGID == 0)
                {
                    MessageBox.Show("该规格可能已经不存在了"); return;
                }

                InstanceForm.BDatabase.BeginTransaction();

                //要被替换的厂家ID
                int _cj_cjid = Convert.ToInt32(tb.Rows[nrow1]["CJID"]);

                //厂家
                string ssql = "update yp_ypcjd set ggid=" + _gg_ggid + ",s_ypspm='" + gg.YPSPM + "',s_yppm='" + gg.YPPM +
                              "',s_ypspmbz='" + gg.YPSPMBZ + "',s_ypgg='" + gg.YPGG + "',s_ypdw='" + Yp.SeekYpdw(gg.YPDW, InstanceForm.BDatabase) + "' where cjid=" + _cj_cjid + " ";
                InstanceForm.BDatabase.DoCommand(ssql);
                //药房库存
                ssql = "update yf_kcmx set ggid=" + _gg_ggid + " where cjid=" + _cj_cjid + " ";
                InstanceForm.BDatabase.DoCommand(ssql);
                //药房批号
                ssql = "update yf_kcph set ggid=" + _gg_ggid + " where cjid=" + _cj_cjid + " ";
                InstanceForm.BDatabase.DoCommand(ssql);
                //药库库存
                ssql = "update yk_kcmx set ggid=" + _gg_ggid + " where cjid=" + _cj_cjid + " ";
                InstanceForm.BDatabase.DoCommand(ssql);
                //药库批号
                ssql = "update yk_kcph set ggid=" + _gg_ggid + " where cjid=" + _cj_cjid + " ";
                InstanceForm.BDatabase.DoCommand(ssql);
                //药房盘点表
                ssql = "update yf_pdtemp set ggid=" + _gg_ggid + " where cjid=" + _cj_cjid + " ";
                InstanceForm.BDatabase.DoCommand(ssql);
                //药库盘点表
                ssql = "update yk_kcph set ggid=" + _gg_ggid + " where cjid=" + _cj_cjid + " ";
                InstanceForm.BDatabase.DoCommand(ssql);
                //药品拆零表
                ssql = "update yp_ypcl set ggid=" + _gg_ggid + " where cjid=" + _cj_cjid + " ";
                InstanceForm.BDatabase.DoCommand(ssql);


                //更新药品货号
                Ypcj   ypcj     = new Ypcj();
                int    _errcode = 0;
                string _errtext = "";
                ypcj.Update_shh(_gg_ggid, out _errcode, out _errtext, InstanceForm.BDatabase);
                if (_errcode != 0)
                {
                    throw new Exception(_errtext);
                }


                //三院数据处理_____保存日志
                Ypcj   cj       = new Ypcj(_cj_cjid, InstanceForm.BDatabase);
                string bz       = "取消药品合并:" + cj.S_YPPM + " CJID=" + cj.CJID + " ";
                Guid   log_djid = Guid.Empty;
                ts_HospData_Share.ts_update_log ts = new ts_HospData_Share.ts_update_log();
                ts.Save_log(ts_HospData_Share.czlx.yp_药品取消合并, bz, "YP_YPCJD", "CJID", _cj_cjid.ToString(), InstanceForm._menuTag.Jgbm, 0, "", out log_djid, InstanceForm.BDatabase);


                InstanceForm.BDatabase.CommitTransaction();


                //三院数据处理___执行同步操作
                string errtext = "";
                ts_HospData_Share.ts_update_type ty = new ts_HospData_Share.ts_update_type((int)ts_HospData_Share.czlx.yp_药品取消合并, InstanceForm.BDatabase);
                if (ty.Bzx == 1) //只有当立即执行标志为1时才执行
                {
                    ts.Pexec_log(log_djid, InstanceForm.BDatabase, out errtext);
                }
                if (errtext != "")
                {
                    MessageBox.Show("取消药品合并成功 " + errtext, "取消合并", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                this.Close();
            }
            catch (System.Exception err)
            {
                UpdateRows = null;
                InstanceForm.BDatabase.RollbackTransaction();
                MessageBox.Show(err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #4
0
파일: Frmhb.cs 프로젝트: Wooyme/HIS-1
        private void butok_Click(object sender, System.EventArgs e)
        {
            DataTable tb = (DataTable)this.myDataGrid1.DataSource;

            DataRow[] rows  = tb.Select("合并=1");
            DataRow[] hbrow = tb.Select("合并=0");
            if (rows.Length == 0)
            {
                MessageBox.Show("没有选择规格", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (hbrow.Length == 0)
            {
                MessageBox.Show("没有可匹配的药品,最少要选择两个药品", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            int _gg_ggid = Convert.ToInt32(rows[0]["ggid"]);

            try
            {
                Ypgg gg = new Ypgg(_gg_ggid, InstanceForm.BDatabase);
                if (gg.GGID == 0)
                {
                    MessageBox.Show("该规格可能已经不存在了"); return;
                }

                string[] ss = new string[hbrow.Length];

                InstanceForm.BDatabase.BeginTransaction();

                for (int i = 0; i <= hbrow.Length - 1; i++)
                {
                    int _cj_cjid = Convert.ToInt32(hbrow[i]["CJID"]);

                    //厂家
                    string ssql = "update yp_ypcjd set ggid=" + _gg_ggid + ",s_ypspm='" + gg.YPSPM + "',s_yppm='" + gg.YPPM +
                                  "',s_ypspmbz='" + gg.YPSPMBZ + "',s_ypgg='" + gg.YPGG + "',s_ypdw='" + Yp.SeekYpdw(gg.YPDW, InstanceForm.BDatabase) + "' where cjid=" + _cj_cjid + " ";
                    InstanceForm.BDatabase.DoCommand(ssql);

                    //药房库存
                    ssql = "update yf_kcmx set ggid=" + _gg_ggid + " where cjid=" + _cj_cjid + " ";
                    InstanceForm.BDatabase.DoCommand(ssql);
                    //药房批号
                    ssql = "update yf_kcph set ggid=" + _gg_ggid + " where cjid=" + _cj_cjid + " ";
                    InstanceForm.BDatabase.DoCommand(ssql);
                    //药库库存
                    ssql = "update yk_kcmx set ggid=" + _gg_ggid + " where cjid=" + _cj_cjid + " ";
                    InstanceForm.BDatabase.DoCommand(ssql);
                    //药库批号
                    ssql = "update yk_kcph set ggid=" + _gg_ggid + " where cjid=" + _cj_cjid + " ";
                    InstanceForm.BDatabase.DoCommand(ssql);
                    //药房盘点表
                    ssql = "update yf_pdtemp set ggid=" + _gg_ggid + " where cjid=" + _cj_cjid + " ";
                    InstanceForm.BDatabase.DoCommand(ssql);
                    //药库盘点表
                    ssql = "update yk_kcph set ggid=" + _gg_ggid + " where cjid=" + _cj_cjid + " ";
                    InstanceForm.BDatabase.DoCommand(ssql);
                    //药品拆零表
                    ssql = "update yp_ypcl set ggid=" + _gg_ggid + " where cjid=" + _cj_cjid + " ";
                    InstanceForm.BDatabase.DoCommand(ssql);

                    //三院数据处理_____保存日志
                    Ypcj   cj       = new Ypcj(_cj_cjid, InstanceForm.BDatabase);
                    string bz       = "将" + hbrow[i]["品名"].ToString() + " CJID=" + hbrow[i]["CJID"] + "的药品合并到新规格 ";
                    Guid   log_djid = Guid.Empty;
                    ts_HospData_Share.ts_update_log ts = new ts_HospData_Share.ts_update_log();
                    ts.Save_log(ts_HospData_Share.czlx.yp_药品合并, bz, "YP_YPCJD", "CJID", _cj_cjid.ToString(), InstanceForm._menuTag.Jgbm, 0, "", out log_djid, InstanceForm.BDatabase);
                    ss[i] = log_djid.ToString();
                }

                //更新药品货号
                Ypcj   ypcj     = new Ypcj();
                int    _errcode = 0;
                string _errtext = "";
                ypcj.Update_shh(_gg_ggid, out _errcode, out _errtext, InstanceForm.BDatabase);
                if (_errcode != 0)
                {
                    throw new Exception(_errtext);
                }

                InstanceForm.BDatabase.CommitTransaction();

                UpdateRows = hbrow;

                //三院数据处理___执行同步操作
                string msg = "";
                for (int i = 0; i <= ss.Length - 1; i++)
                {
                    string errtext = "";
                    ts_HospData_Share.ts_update_type ty = new ts_HospData_Share.ts_update_type((int)ts_HospData_Share.czlx.yp_药品合并, InstanceForm.BDatabase);
                    if (ty.Bzx == 1) //只有当立即执行标志为1时才执行
                    {
                        ts_HospData_Share.ts_update_log ts = new ts_HospData_Share.ts_update_log();
                        ts.Pexec_log(new Guid(ss[i]), InstanceForm.BDatabase, out errtext);
                    }
                    msg = msg + errtext;
                    if (msg != "")
                    {
                        MessageBox.Show("药品合并成功 " + errtext, "合并", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                this.Close();
            }
            catch (System.Exception err)
            {
                UpdateRows = null;
                InstanceForm.BDatabase.RollbackTransaction();
                MessageBox.Show(err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #5
0
파일: Frmxtdzmx.cs 프로젝트: Wooyme/HIS-1
        //数据入账
        private void button1_Click(object sender, System.EventArgs e)
        {
            DataTable tbsl = (DataTable)this.myDataGrid1.DataSource;

            for (int i = 0; i <= tbsl.Rows.Count - 1; i++)
            {
                if (Math.Abs(Convert.ToDouble(tbsl.Rows[i]["数量误差"])) >= 0.2)
                {
                    MessageBox.Show("当有数量误差时不能作账务调整,必须先解决数量误差,请和管理员联系!");
                    return;
                }
            }

            DataTable tbje = (DataTable)this.myDataGrid2.DataSource;

            if (tbje.Rows.Count == 0)
            {
                MessageBox.Show("没有需要作调整的数据"); return;
            }

            if (MessageBox.Show("您确定要将金额误差数据作账务处理行吗 ?", "询问窗", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
            {
                return;
            }

            decimal sumlsje = 0;
            decimal sumpfje = 0;
            decimal sumjhje = 0;

            for (int i = 0; i <= tbje.Rows.Count - 1; i++)
            {
                sumjhje = sumjhje + Convert.ToDecimal(tbje.Rows[i]["进货金额差值"]);
                sumlsje = sumlsje + Convert.ToDecimal(tbje.Rows[i]["零售金额差值"]);
                sumpfje = sumpfje + Convert.ToDecimal(tbje.Rows[i]["批发金额差值"]);
            }

//			if (sumlsje>=100 || sumpfje>=100)
//			{
//				MessageBox.Show("调整金额太大了,系统数据可能存在问题!请和管理员联系");
//				return;
//			}

            long   djh      = 0;                                                                     //单据号
            Guid   djid     = Guid.Empty;
            int    err_code = 0;                                                                     //错误号
            string err_text = "";                                                                    //借误文本
            string sDate    = DateManager.ServerDateTimeByDBType(InstanceForm.BDatabase).ToString(); //登记时间

            this.button1.Enabled = false;


            try
            {
                InstanceForm.BDatabase.BeginTransaction();

                //产生单据号
                djh = Yp.SeekNewDjh(_menuTag.FunctionTag.Trim(), InstanceForm.BCurrentDept.DeptId, InstanceForm.BDatabase);


                //保存单据表头
                YF_DJ_DJMX.SaveDJ(Guid.Empty,
                                  djh,
                                  InstanceForm.BCurrentDept.DeptId,
                                  "012",
                                  InstanceForm.BCurrentDept.DeptId,
                                  0,
                                  Convert.ToDateTime(sDate).ToShortDateString(),
                                  InstanceForm.BCurrentUser.EmployeeId,
                                  Convert.ToDateTime(sDate).ToShortDateString(),
                                  Convert.ToDateTime(sDate).ToLongTimeString(),
                                  "",
                                  "",
                                  "",
                                  "", 0, 0, sumjhje, sumpfje, sumlsje, out djid, out err_code, out err_text, InstanceForm._menuTag.Jgbm, InstanceForm.BDatabase);
                if (err_code != 0)
                {
                    throw new System.Exception(err_text);
                }

                //保存单据明细
                DataTable tb = (DataTable)this.myDataGrid2.DataSource;

                if (tb.Rows.Count == 0)
                {
                    throw new Exception("没有可保存的记录");
                }


                for (int i = 0; i <= tb.Rows.Count - 1; i++)
                {
                    YF_DJ_DJMX.SaveDJMX(Guid.Empty,
                                        djid,
                                        Convert.ToInt32(tb.Rows[i]["cjid"]),
                                        0,
                                        tb.Rows[i]["货号"].ToString(),
                                        tb.Rows[i]["品名"].ToString(),
                                        tb.Rows[i]["商品名"].ToString(),
                                        tb.Rows[i]["规格"].ToString(),
                                        tb.Rows[i]["厂家"].ToString(),
                                        "",
                                        "",
                                        0,
                                        0,
                                        0,
                                        Convert.ToString(tb.Rows[i]["单位"]),
                                        Yp.SeekYpdw(Convert.ToString(tb.Rows[i]["单位"]), InstanceForm.BDatabase),
                                        Convert.ToInt32(tb.Rows[i]["dwbl"]),
                                        0,
                                        0,
                                        0,
                                        Convert.ToDecimal(tb.Rows[i]["进货金额差值"]) * (-1),
                                        Convert.ToDecimal(tb.Rows[i]["批发金额差值"]) * (-1),
                                        Convert.ToDecimal(tb.Rows[i]["零售金额差值"]) * (-1),
                                        djh,
                                        InstanceForm.BCurrentDept.DeptId,
                                        _menuTag.FunctionTag.Trim(),
                                        "",
                                        "",
                                        out err_code, out err_text, InstanceForm.BDatabase, i,
                                        tb.Rows[i]["批次号"].ToString(),
                                        new Guid(tb.Rows[i]["kcid"].ToString()));

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


                //审核单据
                YF_DJ_DJMX.Shdj(djid,
                                sDate, InstanceForm.BDatabase);


                //提交事务
                InstanceForm.BDatabase.CommitTransaction();

                MessageBox.Show(err_text);
            }
            catch (System.Exception err)
            {
                InstanceForm.BDatabase.RollbackTransaction();
                this.button1.Enabled = true;
                MessageBox.Show(err.Message + err.Source);
            }
        }
예제 #6
0
        //汇总药品数量
        private void computeTld(string fyrq)
        {
            bool bGrpByDeptLy = false;

            bGrpByDeptLy = _menuTag.Function_Name.Trim().Equals("Fun_ts_yf_zyfy_cf_ZCY");//中草药上传不按照领药科室分组
            DataTable tb = (DataTable)this.myDataGrid1.DataSource;

            string[] GroupbyField = { "剂型", "品名", "商品名", "规格", "厂家", "单价", "货号", "cjid", "zxdw", "dwbl", "dept_ly" };
            bGrpByDeptLy = true;
            if (bGrpByDeptLy)
            {
                GroupbyField = new string[] { "剂型", "品名", "商品名", "规格", "厂家", "单价", "货号", "cjid", "zxdw", "dwbl" };
            }

            string[] ComputeField = { "ypsl", "金额" };
            string[] CField       = { "sum", "sum" };

            //			TrasenFrame.Classes.TsSet xcset=new TrasenFrame.Classes.TsSet();
            //			xcset.TsDataTable=tb;
            //汇总每个统领分类
            //			DataTable tab=xcset.GroupTable(GroupbyField,ComputeField,CField,"发药='◆' and ypsl<>0");

            DataTable tab;

            DataRow[] selrow;

            if (this.tabControl1.SelectedTab == this.tabPage2)
            {
                selrow = tb.Select("ypsl<>0");
                //selrow = tb.Select("发药='√' and ypsl<>0");
            }
            else
            {
                //if (fyrq != "")
                //    selrow = tb.Select("发药='√' and ypsl<>0 and 发药日期='" + Convertor.IsNull(butfy.Tag, "") + "'");
                //else
                selrow = tb.Select("发药='◆' and ypsl<>0");
            }

            DataTable tbsel = tb.Clone();

            for (int w = 0; w <= selrow.Length - 1; w++)
            {
                tbsel.ImportRow(selrow[w]);
            }
            tab = FunBase.GroupbyDataTable(tbsel, GroupbyField, ComputeField, CField, null);

            DataTable mytb = (DataTable)this.myDataGrid2.DataSource;

            mytb.Rows.Clear();

            DataRow[] Rows = tab.Select("", "剂型");
            decimal   dSum = 0M;

            //添加数据
            for (int x = 0; x <= Rows.Length - 1; x++)
            {
                DataRow row = mytb.NewRow();
                row["序号"]  = mytb.Rows.Count + 1;
                row["剂型"]  = Rows[x]["剂型"];
                row["品名"]  = Rows[x]["品名"];
                row["商品名"] = Rows[x]["商品名"];
                row["规格"]  = Rows[x]["规格"];
                row["厂家"]  = Rows[x]["厂家"];
                row["单价"]  = Rows[x]["单价"];
                //row["库存数"] = Rows[x]["库存数"];
                row["领药数"] = Rows[x]["ypsl"];
                //decimal kcl = Convert.ToDecimal(Rows[x]["库存数"]);
                decimal ypsl = Convert.ToDecimal(Rows[x]["ypsl"]);
                decimal dwbl = Convert.ToDecimal(Rows[x]["dwbl"]);
                //row["缺药数"] = (kcl - ypsl) < 0 ? System.Math.Abs(kcl - ypsl) : 0;
                row["单位"] = Yp.SeekYpdw(Convert.ToInt32(Rows[x]["zxdw"]), InstanceForm.BDatabase);
                Ypcj cj = new Ypcj(Convert.ToInt32(Rows[x]["cjid"]), InstanceForm.BDatabase);
                row["药库单位"] = Convert.ToDouble(Math.Round(ypsl / dwbl, 3)).ToString() + cj.S_YPDW;
                row["金额"]   = Rows[x]["金额"];
                row["货号"]   = Rows[x]["货号"];
                row["cjid"] = Rows[x]["cjid"];
                row["dwbl"] = Rows[x]["dwbl"];
                if (!bGrpByDeptLy)
                {
                    row["领药科室"] = Yp.SeekDeptName(Convert.ToInt32(Rows[x]["dept_ly"]), InstanceForm.BDatabase);
                }
                mytb.Rows.Add(row);
                dSum += decimal.Parse(Rows[x]["金额"].ToString().Trim());
            }

            DataRow rAll = mytb.NewRow();

            rAll["品名"] = "总金额";
            rAll["金额"] = dSum;
            mytb.Rows.Add(rAll);
        }
예제 #7
0
파일: Frmzjtc.cs 프로젝트: Wooyme/HIS-1
        private void butsave_Click(object sender, System.EventArgs e)
        {
            if (Convert.ToInt32(Convertor.IsNull(this.txtzzypmc.Tag, "0")) == 0)
            {
                MessageBox.Show("请输入自制药品名称");
                return;
            }

            try
            {
                this.butsave.Enabled = false;
                InstanceForm.BDatabase.BeginTransaction();

                string    ssql = "";
                string    ylmc = "";
                int       tccjid = 0; decimal lll = 0; string ypdw = ""; int ydwbl = 0; int ylcjid = 0; string zf = "";
                DataTable tb = (DataTable)this.myDataGrid2.DataSource;
                for (int i = 0; i <= tb.Rows.Count - 1; i++)
                {
                    int id = Convert.ToInt32(Convertor.IsNull(tb.Rows[i]["id"], "0"));
                    ylmc   = tb.Rows[i]["原料名称"].ToString();
                    tccjid = Convert.ToInt32(this.txtzzypmc.Tag);
                    lll    = Convert.ToDecimal(Convertor.IsNull(tb.Rows[i]["理论量"], "0"));
                    ypdw   = tb.Rows[i]["单位"].ToString();
                    ydwbl  = Convert.ToInt32(Convertor.IsNull(tb.Rows[i]["ydwbl"], "0"));
                    ylcjid = Convert.ToInt32(Convertor.IsNull(tb.Rows[i]["cjid"], "0"));
                    zf     = this.txtzf.Text.Trim();
                    if (ylcjid != 0)
                    {
                        if (id == 0)
                        {
                            ssql = "insert into yp_zjtc(ylcjid,ypsl,ypdw,ydwbl,tccjid,bz) values(" + ylcjid + "," + lll + "," + Yp.SeekYpdw(ypdw.Trim(), InstanceForm.BDatabase) + "," + ydwbl + "," + tccjid + ",'" + zf.Trim() + "') ";
                        }
                        else
                        {
                            ssql = "update yp_zjtc set (ylcjid,ypsl,ypdw,ydwbl,tccjid,bz) =(" + ylcjid + "," + lll + "," + Yp.SeekYpdw(ypdw.Trim(), InstanceForm.BDatabase) + "," + ydwbl + "," + tccjid + ",'" + zf.Trim() + "') where id=" + id + " ";
                        }
                        InstanceForm.BDatabase.DoCommand(ssql);
                    }
                }

                InstanceForm.BDatabase.CommitTransaction();
                MessageBox.Show("保存成功");
                this.butsave.Enabled = true;
                this.AddDataMydataGrid1(0);
                this.AddDataMydataGrid1(Convert.ToInt32(this.txtzzypmc.Tag));
            }
            catch (System.Exception err)
            {
                this.butsave.Enabled = true;
                InstanceForm.BDatabase.RollbackTransaction();
                MessageBox.Show("发生错误" + err.Message);
            }
        }
예제 #8
0
파일: Frmzjtc.cs 프로젝트: Wooyme/HIS-1
        private void TextKeyUp(object sender, KeyEventArgs e)        //KeyEventArgs
        {
            int     nkey    = Convert.ToInt32(e.KeyCode);
            Control control = (Control)sender;

            if (control.Text.Trim() == "")
            {
                control.Text = ""; control.Tag = "0";
            }

            if ((nkey >= 65 && nkey <= 90) || (nkey >= 48 && nkey <= 57) || (nkey >= 96 && nkey <= 105) || nkey == 8 || nkey == 32 || nkey == 46 || (nkey == 13 && (Convert.ToString(control.Tag) == "0" || Convert.ToString(control.Tag) == "")))
            {
            }
            else
            {
                return;
            }

            try
            {
                string[] GrdMappingName;
                int[]    GrdWidth;
                string[] sfield;
                string   ssql = "";
                DataRow  row;

                Point point = new Point(this.Location.X + control.Location.X, this.Location.Y + control.Location.Y + control.Height * 3);
                switch (control.TabIndex)
                {
                case 0:
                    if (control.Text.Trim() == "")
                    {
                        return;
                    }
                    GrdMappingName = new string[] { "ggid", "cjid", "行号", "品名", "规格", "单位", "货号" };
                    GrdWidth       = new int[] { 0, 0, 30, 150, 100, 40, 60 };
                    sfield         = new string[] { "wbm", "pym", "szm", "ywm", "ypbm" };
                    ssql           = "select a.ggid,cjid,0 rowno,s_ypspm,s_ypgg,s_ypdw,shh from yp_ypcjd a,yp_ypbm b " +
                                     " where a.ggid=b.ggid and a.bdelete=0 and n_ypzlx in(2,4,6) ";                   //and a.n_ypzlx in(select ypzlx from yp_gllx where deptid="+InstanceForm.BCurrentDept.DeptId+")  ";
                    TrasenFrame.Forms.Fshowcard f2 = new TrasenFrame.Forms.Fshowcard(GrdMappingName, GrdWidth, sfield, Constant.CustomFilterType, control.Text.Trim(), ssql);
                    f2.Location = point;
                    f2.Width    = 700;
                    f2.Height   = 300;
                    f2.Text     = "选择自制药品";
                    f2.ShowDialog(this);
                    row = f2.dataRow;
                    if (row != null)
                    {
                        this.txtzzypmc.Text = row["s_ypspm"].ToString();
                        this.txtzzypmc.Tag  = row["cjid"].ToString().Trim();
                        this.SelectNextControl((Control)sender, true, false, true, true);
                    }
                    break;

                case 2:
                    if (control.Text.Trim() == "")
                    {
                        return;
                    }
                    GrdMappingName = new string[] { "ggid", "cjid", "行号", "品名", "规格", "单位", "货号" };
                    GrdWidth       = new int[] { 0, 0, 30, 150, 100, 40, 60 };
                    sfield         = new string[] { "wbm", "pym", "szm", "ywm", "ypbm" };
                    ssql           = "select a.ggid,cjid,0 rowno,s_ypspm,s_ypgg,s_ypdw,shh from yp_ypcjd a,yp_ypbm b " +
                                     " where a.ggid=b.ggid and a.bdelete=0 and a.n_ypzlx in(select ypzlx from yp_gllx where deptid=" + InstanceForm.BCurrentDept.DeptId + ")  ";
                    TrasenFrame.Forms.Fshowcard f3 = new TrasenFrame.Forms.Fshowcard(GrdMappingName, GrdWidth, sfield, Constant.CustomFilterType, control.Text.Trim(), ssql);
                    f3.Location = point;
                    f3.Width    = 700;
                    f3.Height   = 300;
                    f3.Text     = "选择原料";
                    f3.ShowDialog(this);
                    row = f3.dataRow;
                    if (row != null)
                    {
                        this.txtylmc.Text = row["s_ypspm"].ToString();
                        this.txtylmc.Tag  = row["cjid"].ToString().Trim();
                        DataTable tb = Yp.SelectYpcl(InstanceForm.BCurrentDept.DeptId, Convert.ToInt32(row["cjid"]), InstanceForm.BDatabase);
                        if (tb.Rows.Count == 0)
                        {
                            lbldw.Text = row["S_YPDW"].ToString().Trim();
                            lbldw.Tag  = "1";
                        }
                        else
                        {
                            lbldw.Text = Yp.SeekYpdw(Convert.ToInt32(tb.Rows[0]["zxdw"]), InstanceForm.BDatabase);
                            lbldw.Tag  = tb.Rows[0]["dwbl"].ToString();
                        }

                        this.SelectNextControl((Control)sender, true, false, true, true);
                    }
                    break;
                }
            }
            catch (System.Exception err)
            {
                MessageBox.Show("发生错误" + err.Message);
            }
        }