public string SetData(Model.Data_Centre.Link_Mid mid, int col, string authKey) { if (islogin(authKey)) { int x = 0; BLL.Data_Centre.Link_Mid bll = new BLL.Data_Centre.Link_Mid(); Product_Centre pc = new Product_Centre(); int spid = new BLL.Data_Centre.Link().GetSpid(mid.id, mid.iden); if (mid.PriceType == mid.StockType && mid.StockType == 1) { //删除库存和价格同时为最小单位的数据 if (bll.Exists(mid.id, mid.iden)) { if (bll.ExecuteNonQuery(string.Format("delete from link_mid where id={0} and iden={1}", mid.id, mid.iden)) > 0) { } } } else { if (bll.Exists(mid.id, mid.iden)) { //修改 if (bll.Update(mid)) { } } else { //新增 if (bll.Add(mid)) { } } } pc.UpdateStock(spid, mid.iden); new BLL.Data_Centre.Price().Updates((string)pc.ExecuteScalar("SELECT t_id FROM dbo.Link WHERE id=" + mid.id)); } return(""); }
public DataSet GetMaptoolDataList(int PageSize, int PageIndex, bool order, string orderField, bool like, string whereField, string whereString, int BinType, string authKey, int iden) { if (islogin(authKey)) { string tablename = "View_Product_Mid"; BLL.Data_Centre.Link_Mid bll = new BLL.Data_Centre.Link_Mid(); int recordCount, pageCount; string sql = " and iden=" + iden + " "; switch (BinType) { //数据标准化 case 1: { sql += "and id in (SELECT t_id FROM dbo.Link WHERE iden=" + iden + ")"; break; } } if (!string.IsNullOrEmpty(whereString)) { sql += whereString; } whereString = null; var ds = bll.Data_CentreGetList(PageSize, PageIndex, order, orderField, like, whereField, whereString, out recordCount, out pageCount, sql, tablename).DataSet; ds.Tables[0].Columns.Add("StockToolTipText", typeof(string)); ds.Tables[0].Columns.Add("remark", typeof(string)); if (ds.Tables[0].Rows.Count > 0) { sql = string.Format("SELECT * FROM View_Stock1 WHERE iden={0} and id IN ({1})", iden, string.Join(",", ds.Tables[0].AsEnumerable().Select(x => "'" + x.Field <object>("id") + "'"))); var dtTemp = bll.ExecuteTable(sql); foreach (DataRow item in ds.Tables[0].Rows) { item["DrugsBase_DrugName"] = item["DrugsBase_DrugName"].ToString().Trim(); item["DrugsBase_Manufacturer"] = item["DrugsBase_Manufacturer"].ToString().Trim(); item["DrugsBase_ApprovalNumber"] = item["DrugsBase_ApprovalNumber"].ToString().Trim(); var drTemp = dtTemp.Select("id='" + item["id"] + "'").OrderBy(x => x.Field <string>("pihao")).ToArray(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); for (int i = 0; i < drTemp.Count(); i++) { sb.AppendFormat("批号:{0} 效期:{1} 库存:{2}\r\n", drTemp[i]["pihao"].ToString().Trim(), drTemp[i]["sxrq"].ToString().Trim().Replace(" 0:00:00", ""), drTemp[i]["Stock"].ToString().Trim()); if (Library.Lang.DataValidator.IsDateTime(drTemp[i]["sxrq"].ToString())) { if (DateTime.Parse(drTemp[i]["sxrq"].ToString()) < DateTime.Now.AddYears(1)) { item["remark"] = "近效期"; } } } item["StockToolTipText"] = sb.ToString(); } } DataTable dt = new DataTable(); dt.Columns.Add("recordCount"); dt.Columns.Add("pageCount"); var dr = dt.NewRow(); dr["recordCount"] = recordCount; dr["pageCount"] = pageCount; dt.Rows.Add(dr); ds.Tables.Add(dt); return(ds); } else { return(null); } }