//是否自动分配批号库存 public static bool BfpKcph(string ywlx, int deptid, RelationalDatabase db) { string t_kcmx = Yp.Seek_kcmx_table(Convert.ToInt32(deptid), db); string ssql = ""; bool temp = false; if (t_kcmx.Trim() == "yk_kcmx") { ssql = string.Format(" select ywfx from yk_ywlx where ywlx='{0}' ", ywlx); DataTable tb = new DataTable(); tb = db.GetDataTable(ssql); if (tb.Rows.Count > 0) { if (Convertor.IsNull(tb.Rows[0][0], "-") == "-") { temp = true; } } } if (t_kcmx.Trim() == "yf_kcmx") { ssql = string.Format(" select ywfx from yf_ywlx where ywlx='{0}' ", ywlx); DataTable tb = new DataTable(); tb = db.GetDataTable(ssql); if (tb.Rows.Count > 0) { if (Convertor.IsNull(tb.Rows[0][0], "-") == "-") { temp = true; } } } SystemCfg config8050 = new SystemCfg(8050); if (config8050.Config == "1" && temp) //启用自动分配批号库存 且 业务方向为出库 { return(true); } else { return(false); } }
/// <summary> /// FrmShowCard查询窗口 /// </summary> /// <param name="sender">引发的控件</param> /// <param name="_ShowCardType">查询类型权举</param> /// <param name="Fid">其它条件ID</param> /// <param name="point">位置 </param> public static void frmShowCard_wbks(object sender, ShowCardType _ShowCardType, long Fid, Point point, int deptid, RelationalDatabase _DataBase) { Control control = (Control)sender; if (control.Text.Trim() == "") { control.Text = ""; control.Tag = "0"; } string[] GrdMappingName; int[] GrdWidth; string[] sfield; string ssql = ""; Fshowcard f; if (_ShowCardType == ShowCardType.剂型) { GrdMappingName = new string[] { "id", "药品剂型", "拼音码", "五笔码" }; GrdWidth = new int[] { 0, 150, 100, 100 }; //if (Convertor.IsNull(control.Tag.ToString(),"0")!="0") sfield = new string[] { "wbm", "pym", "", "", "" }; //else // sfield=new string[] {"","","","",""}; ssql = "select id,mc,pym,wbm from yp_ypjx where id<>0 ";//yplx="+Convert.ToInt32(Convertor.IsNull(Fid,"0"))+" "; f = new Fshowcard(GrdMappingName, GrdWidth, sfield, FilterType.拼音, control.Text.Trim(), ssql); f.Location = point; f.Text = "药品剂型"; f.ShowDialog(); DataRow row = f.dataRow; if (row != null) { control.Text = row["mc"].ToString(); control.Tag = row["id"].ToString(); } } if (_ShowCardType == ShowCardType.单位) { GrdMappingName = new string[] { "标识", "名称" }; GrdWidth = new int[] { 100, 200 }; //if (Convertor.IsNull(control.Tag.ToString(),"0")!="0") sfield = new string[] { "wbm", "pym", "", "", "" }; //else // sfield=new string[] {"","","","",""}; ssql = "select id,dwmc from yp_ypdw where id<>0 "; f = new Fshowcard(GrdMappingName, GrdWidth, sfield, FilterType.拼音, control.Text.Trim(), ssql); f.Location = point; f.Text = "药品单位"; f.ShowDialog(); DataRow row = f.dataRow; if (row != null) { control.Text = row["dwmc"].ToString(); control.Tag = row["ID"].ToString(); } } if (_ShowCardType == ShowCardType.厂家) { GrdMappingName = new string[] { "id", "生产厂家", "拼音码", "五笔码" }; GrdWidth = new int[] { 0, 150, 100, 100 }; sfield = new string[] { "wbm", "pym", "", "", "" }; ssql = "select id,sccj,pym,wbm from yp_sccj where id<>0 "; f = new Fshowcard(GrdMappingName, GrdWidth, sfield, FilterType.拼音, control.Text.Trim(), ssql); f.Location = point; f.Text = "生产厂家"; f.ShowDialog(); DataRow row = f.dataRow; if (row != null) { control.Text = row["sccj"].ToString(); control.Tag = row["id"].ToString(); } } if (_ShowCardType == ShowCardType.用法) { GrdMappingName = new string[] { "id", "使用方法", "拼音码", "五笔码" }; GrdWidth = new int[] { 0, 150, 100, 100 }; //if (Convertor.IsNull(control.Tag.ToString(),"0")!="0") sfield = new string[] { "wb_code", "py_code", "", "", "" }; //else // sfield=new string[] {"","","","",""}; ssql = "select id,name,py_code,wb_code from jc_usagediction where name is not null "; f = new Fshowcard(GrdMappingName, GrdWidth, sfield, FilterType.拼音, control.Text.Trim(), ssql); f.Location = point; f.Text = "药品用法"; f.ShowDialog(); DataRow row = f.dataRow; if (row != null) { control.Text = row["name"].ToString(); control.Tag = row["id"].ToString(); } } if (_ShowCardType == ShowCardType.药理分类) { GrdMappingName = new string[] { "id", "货位编号", "药品分类", "父分类", "拼音码", "五笔码" }; GrdWidth = new int[] { 0, 60, 150, 150, 100, 100 }; // if (Convertor.IsNull(control.Tag.ToString(),"0")!="0") sfield = new string[] { "wbm", "pym", "", "", "" }; // else // sfield=new string[] {"","","","",""}; ssql = "select id,hwbh,flmc,(select flmc from yp_ylfl where id=a.fid),pym,wbm from yp_ylfl a where yjdbz=1 "; f = new Fshowcard(GrdMappingName, GrdWidth, sfield, FilterType.拼音, control.Text.Trim(), ssql); f.Location = point; f.Width = 600; f.Text = "药理分类"; f.ShowDialog(); DataRow row = f.dataRow; if (row != null) { control.Text = row["flmc"].ToString(); control.Tag = row["id"].ToString(); } } if (_ShowCardType == ShowCardType.供货单位) { GrdMappingName = new string[] { "id", "供货商", "拼音码", "五笔码" }; GrdWidth = new int[] { 0, 150, 100, 100 }; sfield = new string[] { "wbm", "pym", "", "", "" }; ssql = "select ID,ghdwmc,pym,wbm from yp_ghdw WHERE ID<>0 "; f = new Fshowcard(GrdMappingName, GrdWidth, sfield, FilterType.拼音, control.Text.Trim(), ssql); f.Location = point; f.Text = "供货单位"; f.ShowDialog(); DataRow row = f.dataRow; if (row != null) { control.Text = row["ghdwmc"].ToString(); control.Tag = row["id"].ToString(); } } if (_ShowCardType == ShowCardType.包含在科室管理类型中的药品字典) { //SystemCfg cfg = new SystemCfg(8002, _DataBase); //string tablename = "YK_KCMX"; //if (cfg.Config == "1") string tablename = Yp.Seek_kcmx_table(deptid, _DataBase); GrdMappingName = new string[] { "ggid", "cjid", "行号", "品名", "规格", "厂家", "单位", "DWBL", "上次进价", "进货价", "批发价", "零售价", "货号", "基药" }; GrdWidth = new int[] { 0, 0, 0, 140, 90, 90, 30, 0, 70, 60, 60, 60, 100, 45 }; sfield = new string[] { "b.wbm", "b.pym", "szm", "ywm", "ypbm" }; ssql = @"select distinct top 100 a.ggid,a.cjid,0 rowno,s_yppm,s_ypgg,s_sccj,s_ypdw,1 dwbl, (case when scjj=0 or scjj is null then '' else cast(scjj as varchar(50)) end) scjj, a.mrjj, pfj,lsj,shh,(case when GJJBYW=1 then '是' else '' end) 基药 from vi_yp_ypcd a inner join yp_ypbm b " + " on a.ggid=b.ggid left join " + tablename + " c on a.cjid=c.cjid and c.deptid=" + deptid + " where cjbdelete=0 and a.n_ypzlx in(select ypzlx from yp_gllx where deptid=" + deptid + ") "; f = new Fshowcard(GrdMappingName, GrdWidth, sfield, FilterType.拼音, control.Text.Trim(), ssql); f.Location = point; f.Text = "药品输入"; f.Width = 800; f.ShowDialog(); DataRow row = f.dataRow; if (row != null) { control.Tag = row["cjid"].ToString(); } } if (_ShowCardType == ShowCardType.所有药品字典) { GrdMappingName = new string[] { "ggid", "cjid", "行号", "品名", "规格", "厂家", "单位", "DWBL", "批发价", "零售价", "货号" }; GrdWidth = new int[] { 0, 0, 0, 140, 90, 90, 30, 0, 70, 60, 60, 100 }; sfield = new string[] { "b.wbm", "b.pym", "szm", "ywm", "ypbm" }; ssql = "select distinct top 100 a.ggid,a.cjid,0 rowno,s_yppm,s_ypgg,s_sccj,s_ypdw,1 dwbl,pfj,lsj,shh from yp_ypcjd a inner join yp_ypbm b " + " on a.ggid=b.ggid "; f = new Fshowcard(GrdMappingName, GrdWidth, sfield, FilterType.拼音, control.Text.Trim(), ssql); f.Location = point; f.Text = "药品输入"; f.Width = 700; f.ShowDialog(); DataRow row = f.dataRow; if (row != null) { control.Tag = row["cjid"].ToString(); } } if (_ShowCardType == ShowCardType.库存批号列表) { GrdMappingName = new string[] { "行号", "库存量", "单位", "批号", "效期", "库位", "kwid" }; GrdWidth = new int[] { 0, 80, 40, 75, 100, 0, 0 }; sfield = new string[] { "", "", "", "", "" }; if (YpConfig.是否药库(deptid, _DataBase) == true) { ssql = "select 0, kcl,dbo.fun_yp_ypdw(zxdw),ypph,ypxq,'' kwmc,kwid from yk_kcph " + " where deptid=" + deptid + " and cjid=" + Fid + " and bdelete=0 "; } else { ssql = "select 0, kcl,dbo.fun_yp_ypdw(zxdw),ypph,ypxq,'' kwmc,kwid from yf_kcph " + " where deptid=" + deptid + " and cjid=" + Fid + " and bdelete=0 "; } f = new Fshowcard(GrdMappingName, GrdWidth, sfield, FilterType.拼音, "", ssql, _DataBase); f.Location = point; f.Text = "批号列表"; f.ShowDialog(); DataRow row = f.dataRow; if (row != null) { control.Text = row["ypph"].ToString(); } } if (_ShowCardType == ShowCardType.库存药品) { GrdMappingName = new string[] { "ggid", "cjid", "行号", "品名", "规格", "厂家", "库存", "单位", "DWBL", "批发价", "零售价", "货号" }; GrdWidth = new int[] { 0, 0, 30, 140, 90, 90, 60, 30, 0, 60, 60, 100 }; sfield = new string[] { "wbm", "pym", "szm", "ywm", "ypbm" }; /* * update code by pengy 7-2 10:17 * 按系统参数设置获取库存是否大于等于0的数据 */ ssql = "select config from jc_config where id = '8200'"; DataTable paramTable = _DataBase.GetDataTable(ssql); bool ypkc = paramTable != null && paramTable.Rows.Count > 0 && paramTable.Rows[0][0].ToString().Trim() == "1" ? true : false; if (YpConfig.是否药库(deptid, _DataBase) == true) { if (ypkc) { ssql = @"select distinct top 100 a.ggid,cjid,0 rowno,yppm,ypgg,s_sccj,cast(kcl as float) kcl,s_ypdw,1 dwbl,pfj,lsj,shh from vi_yK_kcmx a,yp_ypbm b where a.ggid=b.ggid and KCL >= 0 and deptid=" + deptid + " and bdelete_kc=0 and a.cjid in (select cjid from YP_YPCJD where iswbyp =1)"; } else { ssql = @"select distinct top 100 a.ggid,cjid,0 rowno,yppm,ypgg,s_sccj,cast(kcl as float) kcl,s_ypdw,1 dwbl,pfj,lsj,shh from vi_yK_kcmx a,yp_ypbm b where a.ggid=b.ggid and KCL > 0 and deptid=" + deptid + " and bdelete_kc=0 and a.cjid in (select cjid from YP_YPCJD where iswbyp =1)"; } } else { if (ypkc) { ssql = @"select distinct top 100 a.ggid,cjid,0 rowno,yppm,ypgg,s_sccj,cast(kcl/dwbl as float) kcl,s_ypdw,1 dwbl,pfj,lsj,shh from vi_yf_kcmx a,yp_ypbm b where a.ggid=b.ggid and KCL >= 0 and deptid=" + deptid + " and bdelete_kc=0 and a.cjid in (select cjid from YP_YPCJD where iswbyp =1)"; } else { ssql = @"select distinct top 100 a.ggid,cjid,0 rowno,yppm,ypgg,s_sccj,cast(kcl/dwbl as float) kcl,s_ypdw,1 dwbl,pfj,lsj,shh from vi_yf_kcmx a,yp_ypbm b where a.ggid=b.ggid and KCL > 0 and deptid=" + deptid + " and bdelete_kc=0 and a.cjid in (select cjid from YP_YPCJD where iswbyp =1)"; } } f = new Fshowcard(GrdMappingName, GrdWidth, sfield, FilterType.拼音, control.Text.Trim(), ssql, _DataBase); f.Location = point; f.Text = "库存药品"; f.Width = 700; f.ShowDialog(); DataRow row = f.dataRow; if (row != null) { control.Tag = row["cjid"].ToString(); } } if (_ShowCardType == ShowCardType.库存药品_不区分禁用) { GrdMappingName = new string[] { "ggid", "cjid", "行号", "品名", "规格", "厂家", "库存", "单位", "DWBL", "批发价", "零售价", "货号" }; GrdWidth = new int[] { 0, 0, 30, 140, 90, 90, 60, 30, 0, 60, 60, 100 }; sfield = new string[] { "wbm", "pym", "szm", "ywm", "ypbm" }; if (YpConfig.是否药库(deptid, _DataBase) == true) { ssql = "select distinct top 100 a.ggid,cjid,0 rowno,yppm,ypgg,s_sccj,cast(kcl as float) kcl,s_ypdw,1 dwbl,pfj,lsj,shh from vi_yK_kcmx a,yp_ypbm b where a.ggid=b.ggid and KCL > 0 and deptid=" + deptid + " "; } else { ssql = "select distinct top 100 a.ggid,cjid,0 rowno,yppm,ypgg,s_sccj,cast(kcl/dwbl as float) kcl,s_ypdw,1 dwbl,pfj,lsj,shh from vi_yf_kcmx a,yp_ypbm b where a.ggid=b.ggid and KCL > 0 and deptid=" + deptid + " "; } f = new Fshowcard(GrdMappingName, GrdWidth, sfield, FilterType.拼音, control.Text.Trim(), ssql, _DataBase); f.Location = point; f.Text = "库存药品"; f.Width = 700; f.ShowDialog(); DataRow row = f.dataRow; if (row != null) { control.Tag = row["cjid"].ToString(); } } if (_ShowCardType == ShowCardType.库存药品_外用药品) { GrdMappingName = new string[] { "ggid", "cjid", "行号", "品名", "规格", "厂家", "单位", "DWBL", "批发价", "零售价", "货号" }; GrdWidth = new int[] { 0, 0, 30, 140, 90, 90, 30, 0, 60, 60, 100 }; sfield = new string[] { "wbm", "pym", "szm", "ywm", "ypbm" }; if (YpConfig.是否药库(deptid, _DataBase) == true) { ssql = "select distinct top 100 a.ggid,cjid,0 rowno,yppm,ypgg,s_sccj,s_ypdw,1 dwbl,pfj,lsj,shh from vi_yK_kcmx a,yp_ypbm b where a.ggid=b.ggid and wyyp=1 and deptid=" + deptid + " and bdelete_kc=0 "; } else { ssql = "select distinct top 100 a.ggid,cjid,0 rowno,yppm,ypgg,s_sccj,s_ypdw,1 dwbl,pfj,lsj,shh from vi_yf_kcmx a,yp_ypbm b where a.ggid=b.ggid and wyyp=1 and deptid=" + deptid + " and bdelete_kc=0 "; } f = new Fshowcard(GrdMappingName, GrdWidth, sfield, FilterType.拼音, control.Text.Trim(), ssql, _DataBase); f.Location = point; f.Text = "外用药品"; f.Width = 700; f.ShowDialog(); DataRow row = f.dataRow; if (row != null) { control.Tag = row["cjid"].ToString(); } } #region 加工成品的药品字典 if (_ShowCardType == ShowCardType.加工成品的药品字典) { //SystemCfg cfg = new SystemCfg(8002, _DataBase); //string tablename = "YK_KCMX"; //if (cfg.Config == "1") string tablename = Yp.Seek_kcmx_table(deptid, _DataBase); GrdMappingName = new string[] { "ggid", "cjid", "行号", "品名", "规格", "厂家", "单位", "子类型", "DWBL", "上次进价", "批发价", "零售价", "货号", "基药" }; GrdWidth = new int[] { 0, 0, 0, 140, 90, 90, 30, 60, 0, 70, 60, 60, 100, 45 }; sfield = new string[] { "b.wbm", "b.pym", "szm", "ywm", "ypbm" }; string strWhere = ""; DataTable dtConfig = _DataBase.GetDataTable(string.Format(" select config from jc_config where id = 8042 ", 8042)); if (dtConfig.Rows.Count > 0) { string strCfg = dtConfig.Rows[0][0].ToString(); string[] strs = strCfg.Split('|'); string strCp = strs[0]; string[] scps = strCp.Split(','); for (int i = 0; i < scps.Length; i++) { if (i == 0) { strWhere += string.Format(" and a.n_ypzlx in ({0},", scps[i]); } else { strWhere += string.Format("{0},", scps[i]); } if (i == scps.Length - 1) { strWhere = (strWhere.Substring(0, strWhere.Length - 1)) + ") "; } } } ssql = "select distinct top 80 a.ggid,a.cjid,0 rowno,s_yppm,s_ypgg,s_sccj,s_ypdw, d.mc zlxmc, 1 dwbl,(case when scjj=0 or scjj is null then '' else cast(scjj as varchar(50)) end) scjj,pfj,lsj,shh,(case when GJJBYW=1 then '是' else '' end) 基药 from vi_yp_ypcd a inner join yp_ypbm b " + " on a.ggid=b.ggid left join " + tablename + " c on a.cjid=c.cjid and c.deptid=" + deptid + " inner join yp_ypzlx d on a.ypzlx=d.id where cjbdelete=0" + strWhere + " and a.n_ypzlx in(select ypzlx from yp_gllx where deptid=" + deptid + ") "; try { f = new Fshowcard(GrdMappingName, GrdWidth, sfield, FilterType.拼音, control.Text.Trim(), ssql); } catch { throw new Exception(" 8042参数设置有误! "); return; } f.Location = point; f.Text = "药品输入"; f.Width = 750; f.ShowDialog(); DataRow row = f.dataRow; if (row != null) { control.Tag = row["cjid"].ToString(); } } #endregion #region 制剂成品的药品字典 if (_ShowCardType == ShowCardType.制剂成品的药品字典) { string tablename = Yp.Seek_kcmx_table(deptid, _DataBase); GrdMappingName = new string[] { "ggid", "cjid", "行号", "品名", "规格", "厂家", "单位", "子类型", "DWBL", "上次进价", "批发价", "零售价", "货号", "基药" }; GrdWidth = new int[] { 0, 0, 0, 140, 90, 90, 30, 60, 0, 70, 60, 60, 100, 45 }; sfield = new string[] { "b.wbm", "b.pym", "szm", "ywm", "ypbm" }; string strWhere = ""; ssql = "select distinct top 80 a.ggid,a.cjid,0 rowno,s_yppm,s_ypgg,s_sccj,s_ypdw, d.mc zlxmc, 1 dwbl,(case when scjj=0 or scjj is null then '' else cast(scjj as varchar(50)) end) scjj,pfj,lsj,shh,(case when GJJBYW=1 then '是' else '' end) 基药 from vi_yp_ypcd a inner join yp_ypbm b " + " on a.ggid=b.ggid left join " + tablename + " c on a.cjid=c.cjid and c.deptid=" + deptid + " inner join yp_ypzlx d on a.ypzlx=d.id where cjbdelete=0" + strWhere + " and a.n_ypzlx in(select ypzlx from yp_gllx where deptid=" + deptid + ") "; f = new Fshowcard(GrdMappingName, GrdWidth, sfield, FilterType.拼音, control.Text.Trim(), ssql); f.Location = point; f.Text = "药品输入"; f.Width = 750; f.ShowDialog(); DataRow row = f.dataRow; if (row != null) { control.Tag = row["cjid"].ToString(); } } #endregion }
private void AddData(int yplx, int ypjx, string dm, bool bszkw, bool bkc, string hwmc) { if (cmbyjks.SelectedValue.ToString() == "System.Data.DataRowView") { return; } DataTable myTb = new DataTable(); string ssql = ""; int deptid = Convert.ToInt32(Convertor.IsNull(cmbyjks.SelectedValue, "0")); ssql = @"SELECT '' 序号,dbo.fun_yp_ypjx(ypjx) 剂型,YPPM 品名,ypspm 商品名,ypgg 规格,kcl 库存量,dbo.fun_yp_ypdw(a.ypdw) 单位," + " hwmc 货位编号,A.GGID FROM YP_YPGGD A "; if (bkc == true) { ssql = ssql + " inner join "; } else { ssql = ssql + " left join "; } ssql = ssql + " (SELECT GGID,cast(sum(KCL/DWBL) as float) KCL FROM " + Yp.Seek_kcmx_table(deptid, InstanceForm.BDatabase) + " where deptid=" + deptid + " GROUP BY GGID) b " + " ON A.GGID=B.GGID "; if (bszkw == true || txthw.Text.Trim() != "") { ssql = ssql + " inner join "; } else { ssql = ssql + " left join "; } ssql = ssql + " YP_HWSZ C ON A.GGID=C.GGID and C.deptid=" + deptid + ""; ssql = ssql + " WHERE A.BDELETE=0 "; ssql = ssql + " and ypzlx in(select ypzlx from yp_gllx where deptid=" + deptid + ") "; if (yplx > 0) { ssql = ssql + " and yplx=" + yplx + ""; } if (ypjx > 0) { ssql = ssql + " and ypjx=" + ypjx + ""; } if (dm != "") { ssql = ssql + " and a.ggid in(select ggid from yp_ypbm where ypbm like '%" + txtdm.Text.Trim() + "%' or pym like '%" + txtdm.Text.Trim() + "%' or wbm like '%" + txtdm.Text.Trim() + "%' ) "; } if (hwmc.Trim() != "") { ssql = ssql + " and hwmc like '%" + hwmc + "%'"; } ssql = ssql + " order by hwmc,yplx,ypjx"; myTb = InstanceForm.BDatabase.GetDataTable(ssql); FunBase.AddRowtNo(myTb); myTb.TableName = "Tb"; this.myDataGrid1.DataSource = myTb; this.myDataGrid1.TableStyles[0].MappingName = "Tb"; myTb.AcceptChanges(); }