/// <summary> /// 修改 /// </summary> /// <param name="m">参见模型</param> /// <returns>参见模型</returns> public static Message Mdy(DC_EQUIP_NEW_Model m) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("UPDATE DC_EQUIP_NEW"); sb.AppendFormat(" set "); sb.AppendFormat("EQUIPTYPE={0}", ClsSql.saveNullField(m.EQUIPTYPE)); sb.AppendFormat(",NUMBER={0}", ClsSql.saveNullField(m.NUMBER)); sb.AppendFormat(",NAME={0}", ClsSql.saveNullField(m.NAME)); sb.AppendFormat(",BYORGNO={0}", ClsSql.saveNullField(m.BYORGNO)); sb.AppendFormat(",MODEL={0}", ClsSql.saveNullField(m.MODEL)); sb.AppendFormat(",BUYYEAR={0}", ClsSql.saveNullField(m.BUYYEAR)); sb.AppendFormat(",USESTATE={0}", ClsSql.saveNullField(m.USESTATE)); sb.AppendFormat(",STOREADDR={0}", ClsSql.saveNullField(m.STOREADDR)); sb.AppendFormat(",MARK={0}", ClsSql.saveNullField(m.MARK)); sb.AppendFormat(",JD={0}", ClsSql.saveNullField(m.JD)); sb.AppendFormat(",WD={0}", ClsSql.saveNullField(m.WD)); sb.AppendFormat(",WORTH={0}", ClsSql.saveNullField(m.WORTH)); sb.AppendFormat(",EQUIPAMOUNT={0}", ClsSql.saveNullField(m.EQUIPAMOUNT)); sb.AppendFormat(",REPID={0}", ClsSql.saveNullField(m.REPID)); sb.AppendFormat(",DCSUPPROPUNIT={0}", ClsSql.saveNullField(m.DCSUPPROPUNIT)); sb.AppendFormat(",PRICE={0}", ClsSql.saveNullField(m.PRICE)); sb.AppendFormat(" where DC_EQUIP_NEW_ID= '{0}'", ClsSql.EncodeSql(m.DC_EQUIP_NEW_ID)); bool bln = DataBaseClass.ExeSql(sb.ToString()); if (bln == true) { return(new Message(true, "修改成功!", m.DC_EQUIP_NEW_ID)); } else { return(new Message(false, "修改失败,请检查各输入框是否正确!", "")); } }
/// <summary> /// 增、删、改 /// </summary> /// <param name="m">参见模型</param> /// <returns>参见模型</returns> public static Message Manager(DC_EQUIP_NEW_Model m) { if (m.opMethod == "Add") { //SystemCls.LogSave("3", "通知公告:" + m.INFOTITLE, ClsStr.getModelContent(m)); Message msgUser = BaseDT.DC_EQUIP_NEW.Add(m); return(new Message(msgUser.Success, msgUser.Msg, msgUser.Url)); } if (m.opMethod == "Mdy") { //SystemCls.LogSave("4", "通知公告:" + m.INFOTITLE, ClsStr.getModelContent(m)); Message msgUser = BaseDT.DC_EQUIP_NEW.Mdy(m); return(new Message(msgUser.Success, msgUser.Msg, msgUser.Url)); } if (m.opMethod == "MdyCount") { //SystemCls.LogSave("4", "通知公告:" + m.INFOTITLE, ClsStr.getModelContent(m)); Message msgUser = BaseDT.DC_EQUIP_NEW.MdyCount(m); return(new Message(msgUser.Success, msgUser.Msg, msgUser.Url)); } if (m.opMethod == "Del") { //SystemCls.LogSave("5", "通知公告:" + m.INFOTITLE, ClsStr.getModelContent(m)); Message msgUser = BaseDT.DC_EQUIP_NEW.Del(m); return(new Message(msgUser.Success, msgUser.Msg, msgUser.Url)); } if (m.opMethod == "Del") { //SystemCls.LogSave("5", "通知公告:" + m.INFOTITLE, ClsStr.getModelContent(m)); Message msgUser = BaseDT.DC_EQUIP_NEW.Del(m); return(new Message(msgUser.Success, msgUser.Msg, msgUser.Url)); } return(new Message(false, "无效操作", "")); }
/// <summary> /// 获取列表 /// </summary> /// <param name="sw"></param> /// <returns></returns> public static IEnumerable <DC_EQUIP_NEW_Model> getModelList(DC_EQUIP_NEW_SW sw) { var result = new List <DC_EQUIP_NEW_Model>(); DataTable dt = BaseDT.DC_EQUIP_NEW.getDT(sw);//列表 DataTable dtORG = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW { SYSFLAG = ConfigCls.getSystemFlag() }); //获取单位 DataTable dt32 = BaseDT.T_SYS_DICT.getDT(new T_SYS_DICTSW { DICTTYPEID = "32" }); //数据中心装备类型 DataTable dt36 = BaseDT.T_SYS_DICT.getDT(new T_SYS_DICTSW { DICTTYPEID = "36" }); //使用现状 for (int i = 0; i < dt.Rows.Count; i++) { DC_EQUIP_NEW_Model m = new DC_EQUIP_NEW_Model(); m.DC_EQUIP_NEW_ID = dt.Rows[i]["DC_EQUIP_NEW_ID"].ToString(); m.EQUIPTYPE = dt.Rows[i]["EQUIPTYPE"].ToString(); m.EQUIPTYPEName = BaseDT.T_SYS_DICT.getName(dt32, m.EQUIPTYPE); m.NUMBER = dt.Rows[i]["NUMBER"].ToString(); m.NAME = dt.Rows[i]["NAME"].ToString(); m.BYORGNO = dt.Rows[i]["BYORGNO"].ToString(); m.ORGName = BaseDT.T_SYS_ORG.getName(dtORG, m.BYORGNO); m.MODEL = dt.Rows[i]["MODEL"].ToString(); m.BUYYEAR = PublicClassLibrary.ClsSwitch.SwitDate(dt.Rows[i]["BUYYEAR"].ToString()); m.USESTATE = dt.Rows[i]["USESTATE"].ToString(); m.USESTATEName = BaseDT.T_SYS_DICT.getName(dt36, m.USESTATE); m.STOREADDR = dt.Rows[i]["STOREADDR"].ToString(); m.MARK = dt.Rows[i]["MARK"].ToString(); m.JD = dt.Rows[i]["JD"].ToString(); m.WD = dt.Rows[i]["WD"].ToString(); m.WORTH = dt.Rows[i]["WORTH"].ToString(); m.EQUIPAMOUNT = dt.Rows[i]["EQUIPAMOUNT"].ToString(); m.REPID = dt.Rows[i]["REPID"].ToString(); m.DCSUPPROPUNIT = dt.Rows[i]["DCSUPPROPUNIT"].ToString(); m.PRICE = dt.Rows[i]["PRICE"].ToString(); if (string.IsNullOrEmpty(m.REPID) == false) { m.REPNAME = DC_REPOSITORYCls.getdepotname(m.REPID); } else { m.REPNAME = ""; } result.Add(m); } dt.Clear(); dt.Dispose(); dtORG.Clear(); dtORG.Dispose(); dt32.Clear(); dt32.Dispose(); dt36.Clear(); dt36.Dispose(); return(result); }
/// <summary> /// 通过id获取装备类型 /// </summary> /// <param name="supid"></param> /// <returns></returns> public static string getEQUIPTYPEName(string supid) { DC_EQUIP_NEW_Model m = getModel(new DC_EQUIP_NEW_SW { DC_EQUIP_NEW_ID = supid }); return(m.EQUIPTYPEName); }
/// <summary> /// 删除 /// </summary> /// <param name="m">参见模型</param> /// <returns>参见模型</returns> public static Message Del(DC_EQUIP_NEW_Model m) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("delete DC_EQUIP_NEW"); sb.AppendFormat(" where DC_EQUIP_NEW_ID= '{0}'", ClsSql.EncodeSql(m.DC_EQUIP_NEW_ID)); bool bln = DataBaseClass.ExeSql(sb.ToString()); if (bln == true) { return(new Message(true, "删除成功!", "")); } else { return(new Message(false, "删除失败,请检查各输入框是否正确!", "")); } }
/// <summary> /// 修改 /// </summary> /// <param name="m">参见模型</param> /// <returns>参见模型</returns> public static Message MdyJWD(DC_EQUIP_NEW_Model m) { StringBuilder sb = new StringBuilder(); //HID, HNAME, SN, PHONE, SEX, BIRTH, ONSTATE, BYORGNO sb.AppendFormat("UPDATE DC_EQUIP_NEW"); sb.AppendFormat(" set "); sb.AppendFormat("JD={0}", ClsSql.saveNullField(m.JD)); sb.AppendFormat(",WD={0}", ClsSql.saveNullField(m.WD)); sb.AppendFormat(" where DC_EQUIP_NEW_ID= '{0}'", ClsSql.EncodeSql(m.DC_EQUIP_NEW_ID)); bool bln = DataBaseClass.ExeSql(sb.ToString()); if (bln == true) { return(new Message(true, "修改成功!", "")); } else { return(new Message(false, "修改失败,请检查各输入框是否正确!", "")); } }
/// <summary> /// 修改 /// </summary> /// <param name="m">参见模型</param> /// <returns>参见模型</returns> public static Message MdyCount(DC_EQUIP_NEW_Model m) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("UPDATE DC_EQUIP_NEW"); sb.AppendFormat(" set "); sb.AppendFormat(" WORTH={0}", ClsSql.saveNullField(m.WORTH)); sb.AppendFormat(",EQUIPAMOUNT={0}", ClsSql.saveNullField(m.EQUIPAMOUNT)); sb.AppendFormat(",REPID={0} ", ClsSql.saveNullField(m.REPID)); sb.AppendFormat(" where DC_EQUIP_NEW_ID= '{0}'", ClsSql.EncodeSql(m.DC_EQUIP_NEW_ID)); bool bln = DataBaseClass.ExeSql(sb.ToString()); if (bln == true) { return(new Message(true, "修改成功!", m.DC_EQUIP_NEW_ID)); } else { return(new Message(false, "修改失败,请检查各输入框是否正确!", "")); } }
/// <summary> /// 添加 /// </summary> /// <param name="m">参见模型</param> /// <returns>参见模型</returns> public static Message Add(DC_EQUIP_NEW_Model m) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("INSERT INTO DC_EQUIP_NEW( EQUIPTYPE, NUMBER, NAME, BYORGNO, MODEL, BUYYEAR, USESTATE, STOREADDR, MARK, JD, WD,WORTH,EQUIPAMOUNT,REPID,DCSUPPROPUNIT,PRICE) output inserted.DC_EQUIP_NEW_ID"); sb.AppendFormat(" VALUES("); sb.AppendFormat("{0}", ClsSql.saveNullField(m.EQUIPTYPE)); sb.AppendFormat(",{0}", ClsSql.saveNullField(m.NUMBER)); sb.AppendFormat(",{0}", ClsSql.saveNullField(m.NAME)); sb.AppendFormat(",{0}", ClsSql.saveNullField(m.BYORGNO)); sb.AppendFormat(",{0}", ClsSql.saveNullField(m.MODEL)); sb.AppendFormat(",{0}", ClsSql.saveNullField(m.BUYYEAR)); sb.AppendFormat(",{0}", ClsSql.saveNullField(m.USESTATE)); sb.AppendFormat(",{0}", ClsSql.saveNullField(m.STOREADDR)); sb.AppendFormat(",{0}", ClsSql.saveNullField(m.MARK)); sb.AppendFormat(",{0}", ClsSql.saveNullField(m.JD)); sb.AppendFormat(",{0}", ClsSql.saveNullField(m.WD)); sb.AppendFormat(",{0}", ClsSql.saveNullField(m.WORTH)); sb.AppendFormat(",{0}", ClsSql.saveNullField(m.EQUIPAMOUNT)); sb.AppendFormat(",{0}", ClsSql.saveNullField(m.REPID)); sb.AppendFormat(",{0}", ClsSql.saveNullField(m.DCSUPPROPUNIT)); sb.AppendFormat(",{0}", ClsSql.saveNullField(m.PRICE)); sb.AppendFormat(")"); try { string strid = DataBaseClass.ReturnSqlField(sb.ToString()); if (string.IsNullOrEmpty(strid) == false) { return(new Message(true, "添加成功!", strid)); } else { return(new Message(false, "添加失败!请检查输入框是否正确!", strid)); } } catch (Exception) { throw; } }
/// <summary> /// 护林员上传 /// </summary> /// <param name="filePath">文件路径</param> public static void EQUIPUpload(string filePath) { HSSFWorkbook hssfworkbook; try { using (FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { hssfworkbook = new HSSFWorkbook(file); } } catch (Exception e) { throw e; } NPOI.SS.UserModel.ISheet sheet = hssfworkbook.GetSheetAt(0); int rowCount = sheet.LastRowNum; for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++) { IRow row = sheet.GetRow(i); string[] arr = new string[12]; for (int k = 0; k < arr.Length; k++) { if (k != 6) { arr[k] = row.GetCell(k) == null ? "" : row.GetCell(k).ToString();//循环获取每一单元格内容 } else { arr[k] = row.GetCell(k).DateCellValue.ToString("yyyy-MM-dd"); } } DC_EQUIP_NEW_Model m = new DC_EQUIP_NEW_Model(); //单位 装备类型 名称 编号 型号 使用现状 购买年份 存储地点 数量 价值 经度 纬度 if (string.IsNullOrEmpty(arr[0]) || string.IsNullOrEmpty(arr[2])) { continue; } m.BYORGNO = BaseDT.T_SYS_ORG.getCodeByName(arr[0]); m.NAME = arr[2]; m.NUMBER = arr[3]; m.MODEL = arr[4]; m.BUYYEAR = arr[6]; if (m.BUYYEAR == "9999-12-31") { m.BUYYEAR = "1900-01-01"; } m.STOREADDR = arr[7]; m.EQUIPAMOUNT = arr[8]; m.WORTH = arr[9]; string jd = arr[10]; string wd = arr[11]; if (string.IsNullOrEmpty(jd) == false && string.IsNullOrEmpty(wd) == false) { double[] brr = ClsPositionTrans.GpsTransform(double.Parse(wd), double.Parse(jd), "1"); m.JD = brr[1].ToString(); m.WD = brr[0].ToString(); } if (arr[1].Trim() == "扑救类")//装备类型 { m.EQUIPTYPE = "1"; } else if (arr[1].Trim() == "阻隔类") { m.EQUIPTYPE = "2"; } else if (arr[1].Trim() == "防护类") { m.EQUIPTYPE = "3"; } else if (arr[1].Trim() == "通讯类") { m.EQUIPTYPE = "4"; } else if (arr[1].Trim() == "户外类") { m.EQUIPTYPE = "5"; } else if (arr[1].Trim() == "运输类") { m.EQUIPTYPE = "6"; } else { m.EQUIPTYPE = "1"; } if (arr[5].Trim() == "在用")//使用类型 { m.USESTATE = "1"; } else if (arr[5].Trim() == "储存") { m.USESTATE = "2"; } else if (arr[5].Trim() == "报废") { m.USESTATE = "3"; } else { m.USESTATE = "1"; } var ms = BaseDT.DC_EQUIP_NEW.Add(m); if (string.IsNullOrEmpty(jd) == false && string.IsNullOrEmpty(wd) == false) { TD_EQUIP_Model m1 = new TD_EQUIP_Model(); m1.OBJECTID = ms.Url; m1.NAME = m.NAME; m1.TYPE = m.EQUIPTYPE; m1.JD = jd; m1.WD = wd; m1.Shape = "geometry::STGeomFromText('POINT(" + m1.JD + " " + m1.WD + ")',4326)"; BaseDT.SDE.TD_EQUIP.Add(m1); } string a = row.GetCell(0).ToString(); string a1 = row.GetCell(1).ToString(); string a2 = row.GetCell(2).ToString(); } }
/// <summary> /// 出入库 /// </summary> /// <param name="m">参见模型</param> /// <returns>参见模型</returns> public static Message Manager(DC_DETAILS_Model m) { if (m.opMethod == "INPORT") { if (string.IsNullOrEmpty(m.CountID) == false) { string[] arr = m.CountID.Split('|'); for (int i = 0; i < arr.Length; i++) { if (string.IsNullOrEmpty(arr[i]) == false) { string[] brr = arr[i].Split(','); if (string.IsNullOrEmpty(brr[0].ToString()) == false) { m.SUPID = brr[0].ToString();//物资id m.PRICE = brr[1].ToString(); m.DCREPSUPCOUNT = brr[2].ToString(); m.REPERTORYCOUNT = brr[2].ToString(); BaseDT.DC_DETAILS.Add(m); DataTable dt = BaseDT.DC_SUPPLIES.getDT(new DC_SUPPLIES_SW { SUPID = m.SUPID, REPID = m.REPID }); if (dt.Rows.Count > 0) { DC_SUPPLIES_Model m1 = new DC_SUPPLIES_Model(); string id = BaseDT.DC_SUPPLIES.getid(new DC_SUPPLIES_SW { SUPID = m.SUPID, REPID = m.REPID }); //物资表id string DCsupcount = BaseDT.DC_SUPPLIES.getNum(new DC_SUPPLIES_SW { SUPID = m.SUPID, REPID = m.REPID }); m1.DCSUPCOUNT = (Convert.ToInt32(DCsupcount) + Convert.ToInt32(m.DCREPSUPCOUNT)).ToString(); m1.SUPID = m.SUPID; m1.REPID = m.REPID; m1.DCSUPPLIESID = id; m1.PRICE = m.PRICE; BaseDT.DC_SUPPLIES.Mdy(m1); DC_EQUIP_NEW_Model m2 = new DC_EQUIP_NEW_Model(); m2.DC_EQUIP_NEW_ID = m1.SUPID; m2.EQUIPAMOUNT = m1.DCSUPCOUNT; m2.WORTH = (Convert.ToInt32(m1.PRICE) * Convert.ToInt32(m1.DCSUPCOUNT)).ToString(); m2.REPID = m1.REPID; BaseDT.DC_EQUIP_NEW.MdyCount(m2); } else { DC_SUPPLIES_Model m1 = new DC_SUPPLIES_Model(); m1.DCSUPCOUNT = m.DCREPSUPCOUNT; m1.SUPID = m.SUPID; m1.REPID = m.REPID; m1.PRICE = m.PRICE; BaseDT.DC_SUPPLIES.Add(m1); DC_EQUIP_NEW_Model m2 = new DC_EQUIP_NEW_Model(); m2.DC_EQUIP_NEW_ID = m1.SUPID; m2.EQUIPAMOUNT = m1.DCSUPCOUNT; m2.WORTH = (Convert.ToInt32(m1.PRICE) * Convert.ToInt32(m1.DCSUPCOUNT)).ToString(); m2.REPID = m1.REPID; BaseDT.DC_EQUIP_NEW.MdyCount(m2); } } else { return(new Message(false, "请选择出库的物资", "")); } } } } return(new Message(true, "入库成功", m.NUMBER)); } if (m.opMethod == "EXPORT")//出库 { string str = ""; if (string.IsNullOrEmpty(m.CountID) == false) { string[] arr = m.CountID.Split('|'); for (int i = 0; i < arr.Length; i++) { if (string.IsNullOrEmpty(arr[i]) == false) { string[] brr = arr[i].Split(','); if (string.IsNullOrEmpty(brr[0].ToString()) == false) { //m.SUPID = BaseDT.DC_DETAILS.getsupid(brr[0].ToString()); m.SUPID = brr[0].ToString(); m.DCREPSUPCOUNT = brr[1].ToString(); m.PRICE = BaseDT.DC_SUPPLIES.getPrice(new DC_SUPPLIES_SW { SUPID = m.SUPID }); //m.PRICE = BaseDT.DC_DETAILS.getprice(brr[0].ToString()); DataTable dt = BaseDT.DC_SUPPLIES.getDT(new DC_SUPPLIES_SW { SUPID = m.SUPID, REPID = m.REPID }); if (dt.Rows.Count > 0) { DC_SUPPLIES_Model m1 = new DC_SUPPLIES_Model(); string id = BaseDT.DC_SUPPLIES.getid(new DC_SUPPLIES_SW { SUPID = m.SUPID, REPID = m.REPID }); string DCsupcount = BaseDT.DC_SUPPLIES.getNum(new DC_SUPPLIES_SW { SUPID = m.SUPID, REPID = m.REPID }); //string RECOUNT = BaseDT.DC_DETAILS.getsum(brr[0].ToString());//剩余数量 if (Convert.ToInt32(DCsupcount) >= Convert.ToInt32(m.DCREPSUPCOUNT))//如果剩余数量大于出库数量 { m.REPERTORYCOUNT = (Convert.ToInt32(DCsupcount) - Convert.ToInt32(m.DCREPSUPCOUNT)).ToString(); m.DCDETAILSID = brr[0].ToString(); BaseDT.DC_DETAILS.Add(m); BaseDT.DC_DETAILS.Mdy(m); //更新剩余数量 m1.DCSUPCOUNT = (Convert.ToInt32(DCsupcount) - Convert.ToInt32(m.DCREPSUPCOUNT)).ToString(); m1.SUPID = m.SUPID; m1.REPID = m.REPID; m1.DCSUPPLIESID = id; m1.PRICE = m.PRICE; BaseDT.DC_SUPPLIES.Mdy(m1); str = ""; DC_EQUIP_NEW_Model m2 = new DC_EQUIP_NEW_Model(); m2.DC_EQUIP_NEW_ID = m1.SUPID; m2.EQUIPAMOUNT = m1.DCSUPCOUNT; m2.WORTH = (Convert.ToInt32(m1.PRICE) * Convert.ToInt32(m1.DCSUPCOUNT)).ToString(); m2.REPID = m1.REPID; BaseDT.DC_EQUIP_NEW.MdyCount(m2); } else { return(new Message(true, "超过的部分未出库其他的出库成功", m.NUMBER)); } } else { str = "库存中没有改物资"; } } else { return(new Message(false, "请选择出库的物资", "")); } } } } if (string.IsNullOrEmpty(str) == true) { return(new Message(true, "出库成功", m.NUMBER)); } if (string.IsNullOrEmpty(str) == false) { return(new Message(false, str, "")); } } return(new Message(false, "异常", "")); }