public override void OnLoad(HttpContext context) { base.OnLoad(context); requestBody = new RequestBody(); requestBody.accessToken = context.Request["accessToken"]; requestBody.page = Convert.ToInt32(context.Request["page"]); requestBody.pageSize = Convert.ToInt32(context.Request["pageSize"]); requestBody.oid = Convert.ToInt32(context.Request["oid"]); if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0 || requestBody.oid == 0) { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } else { //验证用户 TokenHelper token = new TokenHelper(); UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken); if (userTokenModel == null) { SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson); } else { ModelAdo <OrderSupplierModel> orderModel = new ModelAdo <OrderSupplierModel>(); List <OrderSupplierModel> models = null; int pagenumber = requestBody.page == 0 ? 1 : requestBody.page; int totalCount = 1; orderModel.PageSize = requestBody.pageSize == 0 ? orderModel.PageSize : requestBody.pageSize; if (requestBody.oid == 0) { models = orderModel.GetList(pagenumber, " cuid=?cuid ", "", out totalCount, "", new MySqlParameter("?cuid", userTokenModel.uid) ); } else { models = orderModel.GetList(pagenumber, " cuid=?cuid AND oid=?oid", "", out totalCount, "", new MySqlParameter("?cuid", Convert.ToInt32(userTokenModel.uid)), new MySqlParameter("?oid", requestBody.oid) ); } if (models.Count >= 1) { responseBody = new ResponseBody { page = 1, pageTotal = (totalCount + orderModel.PageSize - 1) / orderModel.PageSize, total = totalCount, suppliers = models }; responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented); } else { SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson); } } } }
// POST api/values public List<UserModel> Post() { List<UserModel> model = this.Request.Content.ReadAsAsync<List<UserModel>>().Result; HttpRequestMessage rm = this.Request; ModelAdo<UserModel> mUser = new ModelAdo<UserModel>(); return mUser.GetList("", "", ""); }
public override void OnLoad(HttpContext context) { base.OnLoad(context); requestBody = new RequestBody(); requestBody.accessToken = context.Request["accessToken"]; if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0) { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } else { //验证用户 TokenHelper token = new TokenHelper(); UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken); if (userTokenModel == null) { SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson); } else { ModelAdo <UserModel> userModel = new ModelAdo <UserModel>(); List <UserModel> models = userModel.GetList(" id NOT IN (?id) AND status != 1", "", "", new MySqlParameter("?id", userTokenModel.uid)); if (models != null) { List <Friend> Friends = new List <Friend>(); foreach (UserModel model in models) { Friend friend = new Friend(); friend.id = model.id; friend.name = model.name; friend.avatar = model.avatar; Friends.Add(friend); } responseBody = new ResponseBody(); responseBody.Friends = Friends; responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented); } else { SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson); } } } }
public void ProcessRequest(HttpContext context) { int status = 0; ModelAdo <OrderTypeModel> orderTypeModel = new ModelAdo <OrderTypeModel>(); List <OrderTypeModel> list = orderTypeModel.GetList("status = ?status", " sort desc", "", new MySqlParameter("?status", status)); if (list.Count == 0) { status = 0; msg = "未能找到数据集合!"; goto returnJson; } else { output = from model in list select new { id = model.id, pid = model.pid, name = model.name, remark = model.remark, }; } returnJson: Dictionary <string, object> returnJson = new Dictionary <string, object> { { "status", status }, { "msg", msg }, { "output", output } }; string json = JsonConvert.SerializeObject(returnJson, Formatting.Indented); context.Response.ContentType = "application/json"; context.Response.Write(json); }
public override void OnLoad(HttpContext context) { base.OnLoad(context); requestBody = new RequestBody(); requestBody.accessToken = context.Request["accessToken"]; requestBody.page = Convert.ToInt32(context.Request["page"]); requestBody.pageSize = Convert.ToInt32(context.Request["pageSize"]); requestBody.status = Convert.ToInt32(context.Request["status"]); if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0) { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } else { //验证用户 TokenHelper token = new TokenHelper(); UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken); if (userTokenModel == null) { SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson); } else { ModelAdo <OrderModel> orderModel = new ModelAdo <OrderModel>(); List <OrderModel> models = null; int pagenumber = requestBody.page == 0 ? 1 : requestBody.page; int totalCount = 1; orderModel.PageSize = requestBody.pageSize == 0 ? orderModel.PageSize : requestBody.pageSize; if (requestBody.status == 0) { models = orderModel.GetList(pagenumber, " uid=?uid ", "", out totalCount, "", new MySqlParameter("?uid", userTokenModel.uid) ); } else { models = orderModel.GetList(pagenumber, " uid=?uid AND ostatus=?ostatus", "", out totalCount, "", new MySqlParameter("?uid", Convert.ToInt32(userTokenModel.uid)), new MySqlParameter("?ostatus", requestBody.status) ); } if (models.Count >= 1) { //构建返回对象 List <Order> orders = new List <Order>(); foreach (OrderModel model in models) { Order order = new Order(); order.uid = model.uid.ToString(); order.title = model.title; order.createDate = string.Format("{0:d}", StringHelper.GetNomalTime(model.createDate)); order.status = model.ostatus; order.price = model.amount.ToString("f2"); order.oid = model.id.ToString(); order.type = model.otid; Ext from = new Ext(); from.uid = model.uid.ToString(); from.city = model.address1; from.date = string.Format("{0:d}", StringHelper.GetNomalTime(model.time1)); order.from = from; Ext to = new Ext(); to.uid = model.uid.ToString(); to.city = model.address2; to.date = string.Format("{0:d}", StringHelper.GetNomalTime(model.time2)); order.to = to; orders.Add(order); } responseBody = new ResponseBody { page = 1, pageTotal = (totalCount + orderModel.PageSize - 1) / orderModel.PageSize, total = totalCount, orders = orders }; responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented); } else { SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson); } } } }
public override BarcodeModel.MODEL.BaseSearchModel Insert() { //①:解析获取的文件数据,依据每行来读取。 //②:替换对应公司,17-31,16-32[[不存在回滚]] //③:替换PART_CODE,通过SC01003,找到对应的StockName,StockCode[不存在回滚] //④:条码编号:[存在回滚] //⑤:是否存在装箱号条码。有:判断装箱条码中是否存在,如果存在:直接并入该装箱号条码。如果不存在:新建 //⑥:插入原材料: 1:插入,父单据号表; // 2:插入,子单据号明细表; // 3:插入,原材料条码表; // 4:插入,条码历史记录表; lock (objLock) { using (TransactionScope ts = new TransactionScope()) { try { BaseAdo ba = new BaseAdo(); string sql = @" declare @billid varchar(30) exec PROC_GETID 'RW03',@billid output --单据头 insert into RW03(RW03001,RW03002,RW03003,RW03004,RW03005,RW03006,RW03007,RW03008) values(@billid,getdate(),@userid,@username,'','','',N'创建条码') select @billid t"; DataSet dsBillId = ba.GetDataSet(sql, new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName)); string BillId = ""; //总单据号 if (dsBillId != null && dsBillId.Tables[0].Rows.Count > 0) { BillId = dsBillId.Tables[0].Rows[0][0] + ""; } string strImport = System.Text.Encoding.ASCII.GetString(this.Bytes); string[] strImportLine = strImport.Replace("\r", " ").Split('\n'); for (int i = 1; i < strImportLine.Length; i++) { string BarcodeId = "";//导入文件中获取 string PackageId = "";//导入文件中获取 string StockCode = ""; string StockName = ""; string StockSpec = "";//导入文件中获取 string StockUnit = "";//导入文件中获取 string PO = "";//导入文件中获取 decimal StockUnitQty = 0;//导入文件中获取 string Company = "";//导入文件中获取 string SupplierBatch = "";//导入文件中获取 DateTime ProductionTime = DateTime.Now;//导入文件中获取 DateTime ValidityTime = DateTime.Now;//导入文件中获取 string[] strImprotLineItem = strImportLine[i].Split(';'); if (strImprotLineItem[0].Contains("17")) { Company = "31"; } else if (strImprotLineItem[0].Contains("16")) { Company = "32"; } else { throw new Exception("未找到相对应的公司信息!"); } PO = strImprotLineItem[2]; StockSpec = strImprotLineItem[3]; PackageId = strImprotLineItem[5]; BarcodeId = strImprotLineItem[6]; SupplierBatch = strImprotLineItem[7]; StockUnitQty = decimal.Parse(strImprotLineItem[10]); DateTime.TryParse(strImprotLineItem[15], out ProductionTime); DateTime.TryParse(strImprotLineItem[16], out ValidityTime); ModelAdo<RWBarcodeModel> adoBarcode = new ModelAdo<RWBarcodeModel>(); RWBarcodeModel rwModel = adoBarcode.GetModelByID(BarcodeId); if (rwModel != null && rwModel.ID.Length >= 1) { throw new Exception(BarcodeId + "已存在于条码系统中!"); } if (!string.IsNullOrEmpty(PackageId)) { ModelAdo<PackingModel> adoPackage = new ModelAdo<PackingModel>(); PackingModel packageModel = adoPackage.GetModelByID(PackageId); if (packageModel != null) { } else { string sqlPackage = @" --装箱单 insert into RW07(RW07001,RW07002,RW07003,RW07004,RW07005,RW07006,RW07007,RW07008) values(@packageid,getdate(),@userid,@username,0,'',0,2)"; ba.ExecuteSql(sqlPackage, new SqlParameter("packageid", PackageId), new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName)); } } ModelAdo<StockModel> adoStock = new ModelAdo<StockModel>(); List<StockModel> Stocks = adoStock.GetList("SC01003=@stockspec", "", "", new SqlParameter("@stockspec", StockSpec)); if (Stocks != null && Stocks.Count >= 1) { StockCode = Stocks[0].StockCode; StockName = Stocks[0].StockName; StockUnit = Stocks[0].Unit; StockUnitQty = Stocks[0].UQTY; } else { //throw new Exception("未找到相对应的物料信息!"); continue; } string barcodeSql = @" --单据明细 insert into RW04(RW04002,RW04003,RW04004,RW04005) values(getdate(),@billid,@barcodeid,N'创建条码') --历史记录 insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02010,RW02011) values(@barcodeid,getdate(),@userid,@username,@billid,N'创建条码标签') --原材料 insert into RW01(RW01001,RW01002,RW01003,RW01004,RW01005,RW01006,RW01014,RW01024,RW01025,RW01027,RW01031,RW01032,RW01034,RW01035,RW01037,RW01038,RW01040,RW01041,RW01043) values(@barcodeid,@stock,@stockname,@stockspec,@unit,@qty,@po,@userid,@username,@billid,@packageid,1,@company,@supplierbatch,@productiontime ,@validitytime,@tqty,@stype,'PO') "; ba.ExecuteSql(barcodeSql, new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName), new SqlParameter("@stock", StockCode), new SqlParameter("@stockname", StockName), new SqlParameter("@barcodeid", BarcodeId), new SqlParameter("@stockspec", StockSpec), new SqlParameter("@packageid", PackageId), new SqlParameter("@unit", StockUnit), new SqlParameter("@qty", StockUnitQty), new SqlParameter("@tqty", Stocks[0].UQTY), new SqlParameter("@po", PO), new SqlParameter("@stype", Stocks[0].StockType), new SqlParameter("@company", Company), new SqlParameter("@supplierbatch", SupplierBatch), new SqlParameter("@productiontime", ProductionTime), new SqlParameter("@validitytime", ValidityTime), new SqlParameter("@billid", BillId)); } ts.Complete(); } catch (Exception ex) { throw ex; } } } return this; }
public override List<BaseSearchModel> GetALL(bool enableSearch = false) { ModelAdo<FGBillModel> adoBill = new ModelAdo<FGBillModel>(); List<SqlParameter> listParam = new List<SqlParameter>(); StringBuilder sbWhere = new StringBuilder(); sbWhere.Append(" 1=1 "); if (!BeginTime.Equals(DateTime.MinValue) && !EndTime.Equals(DateTime.MinValue)) { sbWhere.Append(" AND FG03002 BETWEEN @BeginTime AND @EndTime "); listParam.Add(new SqlParameter("@BeginTime", BeginTime)); listParam.Add(new SqlParameter("@EndTime", EndTime)); } if (!string.IsNullOrEmpty(this.ID)) { sbWhere.Append(" AND FG03001 = @ID"); listParam.Add(new SqlParameter("@ID", ID)); } if (!string.IsNullOrEmpty(this.UserName)) { sbWhere.Append(" AND FG03004=@UserName"); listParam.Add(new SqlParameter("@UserName", UserName)); } if (!string.IsNullOrEmpty(this.Remark)) { sbWhere.Append(" AND FG03008=@Remark"); listParam.Add(new SqlParameter("@Remark", Remark)); } return adoBill.GetList(sbWhere.ToString(), " FG03002 DESC ", "*", listParam.ToArray()).ConvertAll<BaseSearchModel>(m => m as BaseSearchModel); }
public override List<BaseSearchModel> GetALL(bool enableSearch = false) { ModelAdo<WOWK05Model> adoIssue = new ModelAdo<WOWK05Model>(); List<SqlParameter> listParam = new List<SqlParameter>(); StringBuilder sbWhere = new StringBuilder(); sbWhere.Append(" 1=1 "); if (!BeginReportTime.Equals(DateTime.MinValue) && !EndReportTime.Equals(DateTime.MinValue)) { sbWhere.Append(" AND WK05008 BETWEEN @BeginReportTime AND @EndReportTime "); listParam.Add(new SqlParameter("@BeginReportTime", BeginReportTime)); listParam.Add(new SqlParameter("@EndReportTime", EndReportTime)); } //if (HasExportXml >= 0) //{ // sbWhere.Append(" AND WK05009 = @HasExportXml "); // listParam.Add(new SqlParameter("@HasExportXml", HasExportXml)); //} if (!string.IsNullOrEmpty(CharIndex)) { sbWhere.Append(" AND SUBSTRING(WK05003,4,1)=@CharIndex "); listParam.Add(new SqlParameter("@CharIndex", CharIndex)); } List<BaseSearchModel> models = null; models = adoIssue.GetList(sbWhere.ToString(), SearchOrderBy, "*", listParam.ToArray()).ConvertAll<BaseSearchModel>(m => m as BaseSearchModel); return models; }
public override BaseSearchModel Insert() { if (Barcodes == null || Barcodes.Length == 0) throw new Exception("请扫描或输入待入库的条码标签"); ModelAdo<LocationModel> adoLoc = new ModelAdo<LocationModel>(); List<LocationModel> lm = adoLoc.GetList("SC36001=@wh and SC36002=@bin", "", "", new SqlParameter("@wh", this.Warehouse), new SqlParameter("@bin", this.Bin)); if (lm.Count == 0) throw new Exception("仓库或库位不存在"); using (TransactionScope ts = new TransactionScope()) { ModelAdo<FGBarcodeModel> adoRW = new ModelAdo<FGBarcodeModel>(); StringBuilder sb = new StringBuilder(); foreach (string item in Barcodes) { sb.Append(",'" + item + "'"); } sb.Remove(0, 1); string sql = @" declare @RC int declare @result nvarchar(200) declare @dj varchar(30) set @RC=0 set @result=N'YES' select @RC=count(FG01001) from FG01 where FG01001 IN ([BIDS]) and FG01032>1 if @RC>0 begin set @result=N'不能对已入库的料进行入库操作' end set @RC=0 select @RC=count(distinct(FG01033)) from FG01 where FG01001 IN ([BIDS]) if @RC>1 begin set @result=N'请对同一工单号进行入库操作' end if @result='YES' begin exec PROC_GETID 'FG03',@dj output insert into FG03(FG03001,FG03002,FG03003,FG03004,FG03005,FG03006,FG03007,FG03008) values(@dj,getdate(),@userid,@username,'','','',@Remark) insert into FG02(FG02002,FG02003,FG02004,FG02005,FG02010,FG02011) select FG01001,getdate(),@userid,@username,@dj,N'入库到'+@whstr from FG01 where FG01001 IN ([BIDS]) insert into FG04(FG04002,FG04003,FG04004,FG04005) select getdate(),@dj,FG01001,N'入库到'+@whstr from FG01 where FG01001 IN ([BIDS]) update FG01 set FG01008=@wh,FG01009=@sh,FG01010=getdate(),FG01024=@userid,FG01025=@username,FG01027=@dj,FG01032=2 where FG01001 IN ([BIDS]) end select @result MSG "; sql = sql.Replace("[BIDS]", sb.ToString()); DataSet ds = adoRW.GetDataSet(sql, new SqlParameter("@Remark", this.Remark), new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName), new SqlParameter("@wh", this.Warehouse), new SqlParameter("@sh", this.Bin), new SqlParameter("@whstr", this.Warehouse + "[" + this.Bin + "]")); if (ds != null && ds.Tables[0].Rows.Count > 0) { string msg = ds.Tables[0].Rows[0][0] + ""; if (msg != "YES") throw new Exception(msg); else { this.ExportXML(sb.ToString()); } } ts.Complete(); return this; } }
public override List<BaseSearchModel> GetALL(bool enableSearch = false) { ModelAdo<RWInvoiceModel> ado = new ModelAdo<RWInvoiceModel>(); List<SqlParameter> listParam = new List<SqlParameter>(); StringBuilder sbWhere = new StringBuilder(); sbWhere.Append(" 1=1 "); if (!BeginInvoiceTime.Equals(DateTime.MinValue) && !EndInvoiceTime.Equals(DateTime.MinValue)) { sbWhere.Append(" AND RW18002 BETWEEN @BeginInvoiceTime AND @EndInvoiceTime "); listParam.Add(new SqlParameter("@BeginInvoiceTime", BeginInvoiceTime)); listParam.Add(new SqlParameter("@EndInvoiceTime", EndInvoiceTime)); } if (!String.IsNullOrEmpty(this.ID)) { sbWhere.Append(" AND RW18001 = @ID"); listParam.Add(new SqlParameter("@ID", ID)); } if (Status >= 1) { sbWhere.Append(" AND RW18005 = @Status "); listParam.Add(new SqlParameter("@Status", this.Status)); } List<BaseSearchModel> models = null; if (this.doPager) { int count = 0; ado.PageSize = this.PageSize; models = ado.GetList(this.PageIndex, sbWhere.ToString(), " RW18001 DESC ", out count, "*", listParam.ToArray()).ConvertAll<BaseSearchModel>(m => m as BaseSearchModel); base.totalCount = count; } else { models = ado.GetList(sbWhere.ToString(), " RW18001 DESC ", "*", listParam.ToArray()).ConvertAll<BaseSearchModel>(m => m as BaseSearchModel); } return models; }
public override List<BaseSearchModel> GetALL(bool enableSearch = false) { ModelAdo<RWBarcodeModel> adoBarcode = new ModelAdo<RWBarcodeModel>(); List<SqlParameter> listParam = new List<SqlParameter>(); StringBuilder sbWhere = new StringBuilder(); sbWhere.Append(" 1=1 "); if (!BeginTimeInWH.Equals(DateTime.MinValue) && !EndTimeInWH.Equals(DateTime.MinValue)) { sbWhere.Append(" AND RW01010 BETWEEN @BeginTimeInWH AND @EndTimeInWH "); listParam.Add(new SqlParameter("@BeginTimeInWH", BeginTimeInWH)); listParam.Add(new SqlParameter("@EndTimeInWH", EndTimeInWH)); } if (!BeginTimeOutWH.Equals(DateTime.MinValue) && !EndTimeOutWH.Equals(DateTime.MinValue)) { sbWhere.Append(" AND RW01011 BETWEEN @BeginTimeOutWH AND @EndTimeOutWH "); listParam.Add(new SqlParameter("@BeginTimeOutWH", BeginTimeOutWH)); listParam.Add(new SqlParameter("@EndTimeOutWH", EndTimeOutWH)); } if (!String.IsNullOrEmpty(this.ID)) { sbWhere.Append(" AND RW01001 = @ID"); listParam.Add(new SqlParameter("@ID", ID)); } if (!String.IsNullOrEmpty(this.StockCode)) { sbWhere.Append(" AND RW01002 = @StockCode"); listParam.Add(new SqlParameter("@StockCode", StockCode)); } if (!String.IsNullOrEmpty(this.StockName)) { sbWhere.Append(" AND RW01003 = @StockName"); listParam.Add(new SqlParameter("@StockName", StockName)); } if (!String.IsNullOrEmpty(this.BoxID)) { sbWhere.Append(" AND RW01031 = @BoxID "); listParam.Add(new SqlParameter("@BoxID", this.BoxID)); } if (!String.IsNullOrEmpty(this.SupplierBatch)) { sbWhere.Append(" AND RW01035 = @SupplierBatch "); listParam.Add(new SqlParameter("@SupplierBatch", this.SupplierBatch)); } if (!String.IsNullOrEmpty(this.BatchID)) { sbWhere.Append(" AND RW01036 = @BatchID "); listParam.Add(new SqlParameter("@BatchID", this.BatchID)); } if (!String.IsNullOrEmpty(this.PO)) { sbWhere.Append(" AND RW01014 = @PO "); listParam.Add(new SqlParameter("@PO", this.PO)); } if (Status >= 1) { sbWhere.Append(" AND RW01032 = @Status "); listParam.Add(new SqlParameter("@Status", this.Status)); } List<BaseSearchModel> models = null; if (this.doPager) { int count = 0; adoBarcode.PageSize = this.PageSize; models = adoBarcode.GetList(this.PageIndex, sbWhere.ToString(), SearchOrderBy, out count, "*", listParam.ToArray()).ConvertAll<BaseSearchModel>(m => m as BaseSearchModel); base.totalCount = count; } else { models = adoBarcode.GetList(sbWhere.ToString(), SearchOrderBy, "*", listParam.ToArray()).ConvertAll<BaseSearchModel>(m => m as BaseSearchModel); } return models; }
public override void OnLoad(HttpContext context) { base.OnLoad(context); requestBody = new RequestBody(); requestBody.accessToken = context.Request["accessToken"]; requestBody.withId = Convert.ToInt32(context.Request["withId"]); requestBody.page = Convert.ToInt32(context.Request["page"]); requestBody.pageSize = Convert.ToInt32(context.Request["pageSize"]); if (requestBody.accessToken == null || requestBody.accessToken.Trim().Length == 0 || requestBody.withId == 0) { SystemResponse.Output(SystemResponse.TYPE_NULLPARAMETER, out statusCode, out responseJson); } else { //验证用户 TokenHelper token = new TokenHelper(); UserTokenModel userTokenModel = token.getUserToken(requestBody.accessToken); if (userTokenModel == null) { SystemResponse.Output(SystemResponse.TYPE_EXPIRE, out statusCode, out responseJson); } else { //获取消息列表 ModelAdo <MsgModel> modelAdo = new ModelAdo <MsgModel>(); int pagenumber = requestBody.page == 0 ? 1 : requestBody.page; int totalCount = 1; modelAdo.PageSize = requestBody.pageSize == 0 ? modelAdo.PageSize : requestBody.pageSize; List <MsgModel> models = models = modelAdo.GetList(pagenumber, "(ufrom=?ufrom AND uto=?uto) or (uto=?ufrom AND ufrom=?uto)", "createTime DESC ", out totalCount, "", new MySqlParameter("?ufrom", userTokenModel.uid), new MySqlParameter("?uto", requestBody.withId) ); if (models.Count >= 1) { //构建返回对象 List <Msg> msgs = new List <Msg>(); models.Sort(new idComparer()); foreach (MsgModel model in models) { Msg msg = new Msg(); msg.id = model.id; msg.content = model.content; msg.createTime = string.Format("{0:yyyy/MM/dd HH:mm:ss}", StringHelper.GetNomalTime(model.createTime)); msg.ufrom = model.ufrom; msg.uto = model.uto; msg.type = model.type; msg.status = model.status; msgs.Add(msg); //处理数据为已读 if (msg.status == 0) { model.status = 1; modelAdo.Update(model); } } responseBody = new ResponseBody { page = 1, pageTotal = (totalCount + modelAdo.PageSize - 1) / modelAdo.PageSize, total = totalCount, msgs = msgs }; responseJson = JsonConvert.SerializeObject(responseBody, Formatting.Indented); } else { SystemResponse.Output(SystemResponse.TYPE_NULL, out statusCode, out responseJson); } } } }
public void ProcessRequest(HttpContext context) { if (context.Request["oid"] == null) { status = 0; msg = "订单编号参数不能为空!"; goto returnJson; } string pageSize = context.Request["pageSize"]; string oid = context.Request["oid"]; ModelAdo <SupplierOrderModel> supplierSendModel = new ModelAdo <SupplierOrderModel>(); if (pageSize != null) { supplierSendModel.PageSize = int.Parse(pageSize); } int RecordCount = supplierSendModel.GetRecordCount(" userType=0 "); List <SupplierOrderModel> list = supplierSendModel.GetList(" userType=0 AND (oid=?oid or status is NULL) ", "", "", new MySqlParameter("?oid", oid)); //List<SupplierOrderModel> list = supplierSendModel.GetList("select * from tv_view_supplier_order where userType=0 AND (oid=1 or status is NULL) "); if (list.Count == 0) { status = 0; msg = "未能找到数据集合!"; goto returnJson; } else { pageData = new { recordCount = RecordCount, pageSize = supplierSendModel.PageSize }; Data = from model in list select new { uid = model.uid, status = model.status, oid = model.oid }; output = new { pageData = pageData, Data = Data }; } returnJson: Dictionary <string, object> returnJson = new Dictionary <string, object> { { "status", status }, { "msg", msg }, { "output", output } }; string json = JsonConvert.SerializeObject(returnJson, Formatting.Indented); context.Response.ContentType = "application/json"; context.Response.Write(json); }
public override BaseSearchModel Insert() { ModelAdo<WOModel> adoWO = new ModelAdo<WOModel>(); WOModel modelWO = adoWO.GetModel("MP64001=@wo", "", new SqlParameter("@wo", this.Workorder)); if (modelWO != null) { ModelAdo<ReportModel> adoReport = new ModelAdo<ReportModel>(); List<ReportModel> list = adoReport.GetList("WK02002=@wo", "WK02001", "", new SqlParameter("@wo", this.Workorder)); if (list.Count == 0) { ModelAdo<WOWK01Model> adoWK01 = new ModelAdo<WOWK01Model>(); WOWK01Model wk01 = new WOWK01Model() { WorkOrder=modelWO.WorkOrder, StockCode=modelWO.StockCode, StockName=modelWO.StockName, QTY=modelWO.PlanQTY, Status=1, TotalHour=0 }; adoWK01.Insert(wk01); ModelAdo<WOLineNoGroupModel> adoWOLine = new ModelAdo<WOLineNoGroupModel>(); List<WOLineNoGroupModel> wolineList = adoWOLine.GetList("MP65001=@wo", "MP65003", "", new SqlParameter("@wo", this.Workorder)); int i = 0; string op = ""; foreach (WOLineNoGroupModel item in wolineList) { if (op != item.OperationNO) i = 0; i++; ReportModel modelReport = new ReportModel() { BOMOP = item.OperationNO, BOMOPINDEX = i + "", DeQTY = item.PlanQTY, HadDe = 0, HadDeQTY = 0, StockCode = item.StockCode, StockName = item.StockName, Workorder = item.WO, LineNumber = item.Number, ReportNumber = item.ReportNumber, DeDate = System.DateTime.Now, Warehouse=item.Warehouse }; adoReport.Insert(modelReport); } } // if (!string.IsNullOrEmpty(this.RWID)) // { // ModelAdo<RWBarcodeModel> adoRW = new ModelAdo<RWBarcodeModel>(); // RWBarcodeModel rwModel = adoRW.GetModelByID(this.RWID); // if (rwModel != null) // { // if (this.DeQTY > (float)rwModel.StockUnitQty) // throw new Exception("汇报数量超出条码数量"); // string sql = @" //update RW01 set RW01006=RW01006-@deqty where RW01001=@bid // //insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02010,RW02011) //select RW01001,getdate(),@userid,@username,@dj,N'扣料 工单号'+@wo+' 数量'+convert(varchar(10),@deqty) from RW01 where RW01001=@bid // //update WK02 set WK02002= //"; // } // else // throw new Exception("无效原材料条码"); // } list = adoReport.GetList("WK02002=@wo", "WK02001", "", new SqlParameter("@wo", this.Workorder)); this.ReturnReportList = list; return this; } else throw new Exception("无效工单,请重新确认工单"); }
public override BarcodeModel.MODEL.BaseSearchModel Insert() { lock (objLock) { using (TransactionScope ts = new TransactionScope()) { BaseAdo ba = new BaseAdo(); BaseAdo bascala = new BaseAdo() { ConnectionStr = SysConfig.DBScalaConnection }; string sqlpo = @" select * from view_poline where PC01001=@po and SC01003=@stockspec and Company=@company select * from view_Stock where SC01003=@stockspec and Company=@company "; string sql = @" insert into RW13(RW13002,RW13003,RW13004,RW13005,RW13006,RW13007,RW13008,RW13009,RW13010,RW13011,RW13012,RW13013,RW13014,RW13015,RW13016,RW13017,RW13018,RW13019,RW13020,RW13021,RW13022) values(getdate(),@IMPNO,@userid,@po,@poline,@stockcode,@stockname,@stockspec,@lpn,@supplierbatch,@productdate,@exdate,@qty,@unit,@company,@boxid,@supcode,@supname,@pounit,@saleunit,@stocktype)"; string strImport = System.Text.Encoding.ASCII.GetString(this.Bytes); string[] strImportLine = strImport.Replace("\r", " ").Split('\n'); IMPNO = Guid.NewGuid().ToString(); for (int i = 1; i < strImportLine.Length; i++) { string BarcodeId = "";//导入文件中获取 string PackageId = "";//导入文件中获取 string StockCode = ""; string StockName = ""; string StockSpec = "";//导入文件中获取 string StockUnit = "";//导入文件中获取 string PO = "";//导入文件中获取 decimal StockUnitQty = 0;//导入文件中获取 string Company = "";//导入文件中获取 string SupplierBatch = "";//导入文件中获取 string supplierCode = ""; string supplierName = ""; double purunit = 1; double saleunit = 1; string stockType = "02"; string poline = ""; DateTime ProductionTime = DateTime.Now;//导入文件中获取 DateTime ValidityTime = DateTime.Now;//导入文件中获取 string[] strImprotLineItem = strImportLine[i].Split(';'); switch (strImprotLineItem[0]) { case "11117": Company = "31"; break; case "11116": Company = "32"; break; default: Company = "-"; break; } PO = strImprotLineItem[2]; StockSpec = strImprotLineItem[3]; PackageId = strImprotLineItem[5]; BarcodeId = strImprotLineItem[6]; SupplierBatch = strImprotLineItem[7]; StockUnitQty = decimal.Parse(strImprotLineItem[10]); DateTime.TryParse(strImprotLineItem[15], out ProductionTime); DateTime.TryParse(strImprotLineItem[16], out ValidityTime); DataSet ds = bascala.GetDataSet(sqlpo, new SqlParameter("@Company", Company), new SqlParameter("@stockspec", StockSpec), new SqlParameter("@po", PO)); if (ds.Tables[0].Rows.Count > 0) { poline = ds.Tables[0].Rows[0]["PC03002"] + ""; supplierCode = ds.Tables[0].Rows[0]["PL01001"] + ""; supplierName = ds.Tables[0].Rows[0]["PL01002"] + ""; } if (ds.Tables[1].Rows.Count > 0) { double.TryParse(ds.Tables[1].Rows[0]["SC01072"] + "", out purunit); double.TryParse(ds.Tables[1].Rows[0]["SC01073"] + "", out saleunit); stockType = ds.Tables[1].Rows[0]["SC01035"] + ""; StockCode = ds.Tables[1].Rows[0]["SC01001"] + ""; StockName = ds.Tables[1].Rows[0]["SC01002"] + ""; StockUnit = ds.Tables[1].Rows[0]["UNIT"] + ""; } ba.ExecuteSql(sql, new SqlParameter("@IMPNO", IMPNO), new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@po", PO), new SqlParameter("@poline", poline), new SqlParameter("@stockcode", StockCode), new SqlParameter("@stockname", StockName), new SqlParameter("@stockspec", StockSpec), new SqlParameter("@lpn", BarcodeId), new SqlParameter("@supplierbatch", SupplierBatch), new SqlParameter("@productdate", ProductionTime), new SqlParameter("@exdate", ValidityTime), new SqlParameter("@qty", StockUnitQty), new SqlParameter("@unit", StockUnit), new SqlParameter("@company", Company), new SqlParameter("@boxid", PackageId), new SqlParameter("@supcode", supplierCode), new SqlParameter("@supname", supplierName), new SqlParameter("@pounit", purunit), new SqlParameter("@saleunit", saleunit), new SqlParameter("@stocktype", stockType)); } ModelAdo<USBarcodeModel> adoUB = new ModelAdo<USBarcodeModel>(); this.ReturnUSBarcodes = adoUB.GetList("RW13003=@impno", "", "", new SqlParameter("@impno", IMPNO)); ModelAdo<USBarcodeGroup> adoUBG = new ModelAdo<USBarcodeGroup>(); this.ReturnUSBarcodeGroups = adoUBG.GetList("RW13003=@impno", "", "", new SqlParameter("@impno", IMPNO)); ts.Complete(); } } return this; }
public override BaseSearchModel Insert() { using (TransactionScope ts = new TransactionScope()) { string sql = @" declare @dj varchar(30) exec PROC_GETID 'RW03',@dj output --单据头 insert into RW03(RW03001,RW03002,RW03003,RW03004,RW03005,RW03006,RW03007,RW03008) values(@dj,getdate(),@userid,@username,'','','',N'US导入创建条码') --装箱标签 insert into RW07(RW07001,RW07002,RW07003,RW07004,RW07005,RW07006,RW07007,RW07008) select RW13017,getdate(),@userid,@username,0,'',0,2 from RW13 where RW13003=@impno and isnull(RW13006,'')<>'' and isnull(RW13017,'')<>'' and isnull(RW13007,'')<>'' and RW13010 not in (select RW01001 from RW01) group by RW13017 --单据明细 insert into RW04(RW04002,RW04003,RW04004,RW04005) select getdate(),@dj,RW13010,N'US导入创建条码' from RW13 where RW13003=@impno and isnull(RW13006,'')<>'' and isnull(RW13007,'')<>'' and RW13010 not in (select RW01001 from RW01) --历史记录 insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02010,RW02011) select RW13010,getdate(),@userid,@username,@dj,N'US导入创建条码' from RW13 where RW13003=@impno and isnull(RW13006,'')<>'' and isnull(RW13007,'')<>'' and RW13010 not in (select RW01001 from RW01) --原材料 insert into RW01(RW01001,RW01002,RW01003,RW01004,RW01005,RW01006,RW01012,RW01013,RW01014,RW01015,RW01024,RW01025,RW01027,RW01031,RW01032,RW01034,RW01035,RW01037,RW01038,RW01041,RW01043,RW01044,RW01045) select RW13010,RW13007,RW13008,RW13009,RW13015,RW13014,RW13018,RW13019,RW13005,RW13006,@userid,@username,@dj,RW13017,1,RW13016,RW13011,RW13012,RW13013,RW13022,'PO',RW13020,RW13021 from RW13 where RW13003=@impno and isnull(RW13006,'')<>'' and isnull(RW13007,'')<>'' and RW13010 not in (select RW01001 from RW01) --删除成功的 delete from RW13 where RW13010 in (select RW01001 from RW01) "; BaseAdo ba = new BaseAdo(); ba.ExecuteSql(sql, new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName), new SqlParameter("@impno", IMPNO)); ModelAdo<USBarcodeModel> adoUB = new ModelAdo<USBarcodeModel>(); this.ReturnUSBarcodes = adoUB.GetList("RW13003=@impno", "", "", new SqlParameter("@impno", IMPNO)); ModelAdo<USBarcodeGroup> adoUBG = new ModelAdo<USBarcodeGroup>(); this.ReturnUSBarcodeGroups = adoUBG.GetList("RW13003=@impno", "", "", new SqlParameter("@impno", IMPNO)); ts.Complete(); return this; } }
public override BaseSearchModel Insert() { if (Barcodes == null || Barcodes.Length == 0) throw new Exception("请扫描或输入待入库的条码标签"); ModelAdo<LocationModel> adoLoc = new ModelAdo<LocationModel>(); List<LocationModel> lm = adoLoc.GetList("SC36001=@wh and SC36002=@bin", "", "", new SqlParameter("@wh", this.Warehouse), new SqlParameter("@bin", this.Bin)); if (lm.Count == 0) throw new Exception("仓库或库位不存在"); using (TransactionScope ts = new TransactionScope()) { ModelAdo<RWBarcodeModel> adoRW = new ModelAdo<RWBarcodeModel>(); StringBuilder sb = new StringBuilder(); foreach (string item in Barcodes) { sb.Append(",'" + item + "'"); } sb.Remove(0, 1); string sql = @" declare @RC int declare @result nvarchar(200) declare @dj varchar(30) set @RC=0 set @result=N'YES' select @RC=count(RW01001) from RW01 where RW01001 IN ([BIDS]) and RW01032>1 if @RC>0 begin set @result=N'已入库的料不可再入库' end set @RC=0 select @RC=count(distinct(RW01014)) from RW01 where RW01001 IN ([BIDS]) if @RC>1 begin set @result=N'多张采购单请分批收货' end set @RC=0 select @RC=count(distinct(RW01043)) from RW01 where RW01001 IN ([BIDS]) if @RC>1 begin set @result=N'PO收货、WO收货以及STOCK RECEIVE请分开操作' end if @result='YES' begin exec PROC_GETID 'RW03',@dj output insert into RW03(RW03001,RW03002,RW03003,RW03004,RW03005,RW03006,RW03007,RW03008) values(@dj,getdate(),@userid,@username,'','','',@Remark) insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02010,RW02011) select RW01001,getdate(),@userid,@username,@dj,N'入库到'+@whstr from RW01 where RW01001 IN ([BIDS]) insert into RW04(RW04002,RW04003,RW04004,RW04005) select getdate(),@dj,RW01001,N'入库到'+@whstr from RW01 where RW01001 IN ([BIDS]) update RW01 set RW01008=@wh,RW01009=@sh,RW01010=getdate(),RW01024=@userid,RW01025=@username,RW01027=@dj,RW01032=2 where RW01001 IN ([BIDS]) UPDATE WK01 SET WK01006=getdate() where WK01006 is null and WK01004<= (select sum(RW01006) FROM RW01 WHERE RW01032=2 and RW01033=WK01001 and RW01002=WK01002 GROUP BY RW01033,RW01002) end select @result MSG "; sql = sql.Replace("[BIDS]", sb.ToString()); DataSet ds = adoRW.GetDataSet(sql, new SqlParameter("@Remark", this.Remark), new SqlParameter("@userid", this.LoginUserID), new SqlParameter("@username", this.LoginUserName), new SqlParameter("@wh", this.Warehouse), new SqlParameter("@sh", this.Bin), new SqlParameter("@whstr", this.Warehouse + "[" + this.Bin + "]")); if (ds != null && ds.Tables[0].Rows.Count > 0) { string msg = ds.Tables[0].Rows[0][0] + ""; if (msg != "YES") throw new Exception(msg); else { this.ExportXMLPO(sb.ToString()); } } ts.Complete(); return this; } }
public override BarcodeModel.MODEL.BaseSearchModel Insert() { if (Barcodes == null || Barcodes.Length == 0) throw new Exception("请扫描或输入待入库的条码标签"); ModelAdo<LocationModel> adoLoc = new ModelAdo<LocationModel>(); List<LocationModel> lm = adoLoc.GetList("SC36001=@wh and SC36002=@bin", "", "", new SqlParameter("@wh", this.Warehouse), new SqlParameter("@bin", this.Bin)); if (lm.Count == 0) throw new Exception("仓库或库位不存在"); //①:修改原材料领料单RW08状态 :RW08008 int 状态(1已申请 2部分发货 3关闭) //②:修改原材料领料单ITEMRW09已领和剩余数量 //③:插入RW10 原材料领料单BARCODE 中间表 //④:修改条码信息表: //⑤:插入RW03原材料单据表 //⑥:插入RW04原材料单据明细表 //⑦:插入RW02 原材料历史记录 using (TransactionScope ts = new TransactionScope()) { ModelAdo<RWBarcodeModel> adoRW = new ModelAdo<RWBarcodeModel>(); List<SqlParameter> parameters = new List<SqlParameter>(); StringBuilder sb = new StringBuilder(); foreach (string item in Barcodes) { sb.Append(",'" + item + "'"); } sb.Remove(0, 1); string sql = @" declare @RC int declare @result nvarchar(200) declare @dj varchar(30) set @RC=0 set @result=N'YES' select @RC=count(RW01001) from RW01 where RW01001 IN ([BIDS]) and RW01032 <> 2 if @RC>0 begin set @result=N'存在不能做领料操作的信息,不能进行领料操作' end if @result='YES' begin declare @calcstatus int Update RW09 set RW09005=@userid,RW09006=@username,RW09011=@ReceivedCount, RW09012=@ReceiveSurplusCount where RW09001=@ReceiveLine set @calcstatus=2 select @calcstatus=SUM(RW09012) from RW09 where RW09003=@ReceiveID if @calcstatus>0 begin set @ReceiveStatus=2 end else begin set @ReceiveStatus=3 end Update RW08 set RW08008=@ReceiveStatus where RW08001=@ReceiveID insert into RW10(RW10002,RW10003,RW10004,RW10005,RW10006,RW10007) select getdate(),@userid,@username,@ReceiveID,@ReceiveLine,RW01001 from RW01 where RW01001 IN ([BIDS]) exec PROC_GETID 'RW03',@dj output insert into RW03(RW03001,RW03002,RW03003,RW03004,RW03005,RW03006,RW03007,RW03008) values(@dj,getdate(),@userid,@username,'','',@ReceiveID,@Remark) insert into RW02(RW02002,RW02003,RW02004,RW02005,RW02010,RW02011) select RW01001,getdate(),@userid,@username,@dj,N'领料单['+ @ReceiveID +'];移库到'+@whstr from RW01 where RW01001 IN ([BIDS]) insert into RW04(RW04002,RW04003,RW04004,RW04005) select getdate(),@dj,RW01001,N'领料单['+ @ReceiveID +']; 移库到'+@whstr from RW01 where RW01001 IN ([BIDS]) update RW01 set RW01016 =RW01008 ,RW01017 = RW01009,RW01008=@wh,RW01009=@sh,RW01024=@userid,RW01025=@username,RW01027=@dj,RW01032=3 where RW01001 IN ([BIDS]) end select @result MSG "; parameters.Add(new SqlParameter("@userid", this.LoginUserID)); parameters.Add(new SqlParameter("@username", this.LoginUserName)); parameters.Add(new SqlParameter("@Remark", this.Remark)); parameters.Add(new SqlParameter("@ReceiveID", this.ReceiveID)); parameters.Add(new SqlParameter("@ReceiveStatus", this.ReceiveStatus)); parameters.Add(new SqlParameter("@ReceiveLine", this.ReceiveLine)); parameters.Add(new SqlParameter("@ReceivedCount", this.ReceivedCount)); parameters.Add(new SqlParameter("@ReceiveSurplusCount", this.ReceiveSurplusCount)); parameters.Add(new SqlParameter("@wh", this.Warehouse)); parameters.Add(new SqlParameter("@sh", this.Bin)); parameters.Add(new SqlParameter("@whstr", this.Warehouse + "[" + this.Bin + "]")); sql = sql.Replace("[BIDS]", sb.ToString()); DataSet ds = adoRW.GetDataSet(sql, parameters.ToArray()); if (ds != null && ds.Tables[0].Rows.Count > 0) { string msg = ds.Tables[0].Rows[0][0] + ""; if (msg != "YES") throw new Exception(msg); else { this.ExportXML(sb.ToString()); } } ts.Complete(); return this; } }
public override List<BaseSearchModel> GetALL(bool enableSearch = false) { ModelAdo<RWHistoryModel> adoRW = new ModelAdo<RWHistoryModel>(); List<SqlParameter> listParam = new List<SqlParameter>(); StringBuilder sbWhere = new StringBuilder(); sbWhere.Append(" 1=1 "); if (!string.IsNullOrEmpty(this.BarcodeID)) { sbWhere.Append(" AND RW02002 = @BarcodeID"); listParam.Add(new SqlParameter("@BarcodeID", this.BarcodeID)); } return adoRW.GetList(sbWhere.ToString(), " RW02001 DESC ", "*", listParam.ToArray()).ConvertAll<BaseSearchModel>(m => m as BaseSearchModel); }
public override List<BaseSearchModel> GetALL(bool enableSearch = false) { ModelAdo<ReceiveDetailModel> adoRDetails = new ModelAdo<ReceiveDetailModel>(); List<SqlParameter> listParam = new List<SqlParameter>(); StringBuilder sbWhere = new StringBuilder(); sbWhere.Append(" 1=1 "); if (!string.IsNullOrEmpty(ReceiveID)) { sbWhere.Append(" AND RW09003 = @ReceiveID "); listParam.Add(new SqlParameter("@ReceiveID", this.ReceiveID)); } List<BaseSearchModel> models = null; if (this.doPager) { int count = 0; adoRDetails.PageSize = this.PageSize; models = adoRDetails.GetList(this.PageIndex, sbWhere.ToString(), " RW09001 DESC ", out count, "*", listParam.ToArray()).ConvertAll<BaseSearchModel>(m => m as BaseSearchModel); base.totalCount = count; } else { models = adoRDetails.GetList(sbWhere.ToString(), " RW09001 DESC ", "*", listParam.ToArray()).ConvertAll<BaseSearchModel>(m => m as BaseSearchModel); } return models; }
public override List<BaseSearchModel> GetALL(bool enableSearch = false) { ModelAdo<WCTimeModel> adoWCTime = new ModelAdo<WCTimeModel>(); List<SqlParameter> listParam = new List<SqlParameter>(); StringBuilder sbWhere = new StringBuilder(); sbWhere.Append(" 1=1 "); if (!QueryBeginTime.Equals(DateTime.MinValue) && !QueryEndTime.Equals(DateTime.MinValue)) { sbWhere.Append(" AND DueDate BETWEEN @QueryBeginTime AND @QueryEndTime "); listParam.Add(new SqlParameter("@QueryBeginTime", QueryBeginTime)); listParam.Add(new SqlParameter("@QueryEndTime", QueryEndTime)); } List<BaseSearchModel> models = null; models = adoWCTime.GetList(sbWhere.ToString(), SearchOrderBy, "*", listParam.ToArray()).ConvertAll<BaseSearchModel>(m => m as BaseSearchModel); return models; }