/// <summary> /// 出库 /// </summary> /// <param name="inventorySchedule">出库明细</param> /// <returns></returns> public bool outHouse(InventorySchedule inventorySchedule) { bool rs = false; inventory.Amount = inventoryLogic.getInventoryByID(inventorySchedule.DrugID).Amount; if (inventorySchedule.Count > inventory.Amount) { return(rs); } //修改数量 inventory.Amount -= inventorySchedule.Count; //修改库存sql string sqlUpdate = $"UPDATE \"public\".\"Inventory\" SET \"Amount\" = '{inventory.Amount }', \"UpdateTime\" = now() WHERE \"DrugID\" " + $"= '{inventorySchedule.DrugID}'"; //插入库存明细sql string sqlInvSchedule = $"INSERT INTO \"InventorySchedule\"( \"DrugID\", \"Count\",\"Operator\", \"OperatorTime\") " + $"VALUES ('{inventorySchedule.DrugID}','{-inventorySchedule.Count}','{inventorySchedule.Operator}',now())"; try { using (var db = new QWPlatform.IService.DbContext(true)) { int j = db.Sql(sqlInvSchedule).Execute(); if (j > 0) { int i = db.Sql(sqlUpdate).Execute(); } } } catch (Exception ex) { } return(rs); }
/// <summary> /// 药品入库 /// </summary> /// <param name="iSche">入库信息</param> /// <returns></returns> public string inHouse(InventorySchedule iSche) { string rs = "入库失败"; if (iSche.Count < 0) { rs = "数量不能小于0"; } inventory = inventoryLogic.getInventoryByID(iSche.DrugID); if (inventory is null) { rs = "药品ID:" + iSche + "不存在"; } //插入库存sql string sqlInv = $"INSERT INTO \"Inventory\"( \"DrugID\", \"Amount\", \"UpdateTime\",\"Operator\", \"StroehouseID\") " + $"VALUES ('{iSche.DrugID}','{iSche.Count}',now(),'{iSche.Operator}','{iSche.Storehouse}')"; //修改库存sql string sqlUpdate = $"UPDATE \"public\".\"Inventory\" SET \"Amount\" = '{iSche.Count}', \"UpdateTime\" = now() WHERE \"DrugID\" " + $"= '{iSche.DrugID}'"; //插入库存明细sql string sqlInvSchedule = $"INSERT INTO \"InventorySchedule\"( \"DrugID\", \"Count\",\"Operator\", \"OperatorTime\") " + $"VALUES ('{iSche.DrugID}','{iSche.Count}','{iSche.Operator}',now())"; using (var db = new QWPlatform.IService.DbContext(true)) { //插入数据明细 try { int j = db.Sql(sqlInvSchedule).Execute(); if (inventory.Amount == 0) { //如果第一次入库,新增库存 int i = db.Sql(sqlInv). Execute(); } //如果非第一次入库,修改库存 int k = db.Sql(sqlUpdate).Execute(); if (k < 1) { rs = "入库失败"; } } catch (Exception ex) { rs = ex.ToString(); } } return(rs); }
public IRequest Marshall(PutBucketInventoryConfigurationRequest putBucketInventoryConfigurationRequest) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0360: Unknown result type (might be due to invalid IL or missing references) IRequest val = new DefaultRequest(putBucketInventoryConfigurationRequest, "AmazonS3"); val.set_HttpMethod("PUT"); val.set_ResourcePath("/" + S3Transforms.ToStringValue(putBucketInventoryConfigurationRequest.BucketName)); val.AddSubResource("inventory"); if (putBucketInventoryConfigurationRequest.IsSetInventoryId()) { val.AddSubResource("id", S3Transforms.ToStringValue(putBucketInventoryConfigurationRequest.InventoryId)); } StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture); using (XmlWriter xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings { Encoding = Encoding.UTF8, OmitXmlDeclaration = true })) { if (putBucketInventoryConfigurationRequest.IsSetInventoryConfiguration()) { InventoryConfiguration inventoryConfiguration = putBucketInventoryConfigurationRequest.InventoryConfiguration; xmlWriter.WriteStartElement("InventoryConfiguration", "http://s3.amazonaws.com/doc/2006-03-01/"); if (inventoryConfiguration != null) { if (inventoryConfiguration.IsSetDestination()) { InventoryDestination destination = inventoryConfiguration.Destination; xmlWriter.WriteStartElement("Destination", "http://s3.amazonaws.com/doc/2006-03-01/"); if (destination.isSetS3BucketDestination()) { InventoryS3BucketDestination s3BucketDestination = destination.S3BucketDestination; xmlWriter.WriteStartElement("S3BucketDestination", "http://s3.amazonaws.com/doc/2006-03-01/"); if (s3BucketDestination.IsSetAccountId()) { xmlWriter.WriteElementString("AccountId", "http://s3.amazonaws.com/doc/2006-03-01/", S3Transforms.ToXmlStringValue(s3BucketDestination.AccountId)); } if (s3BucketDestination.IsSetBucketName()) { xmlWriter.WriteElementString("Bucket", "http://s3.amazonaws.com/doc/2006-03-01/", S3Transforms.ToXmlStringValue(s3BucketDestination.BucketName)); } if (s3BucketDestination.IsSetInventoryFormat()) { xmlWriter.WriteElementString("Format", "http://s3.amazonaws.com/doc/2006-03-01/", S3Transforms.ToXmlStringValue(ConstantClass.op_Implicit(s3BucketDestination.InventoryFormat))); } if (s3BucketDestination.IsSetPrefix()) { xmlWriter.WriteElementString("Prefix", "http://s3.amazonaws.com/doc/2006-03-01/", S3Transforms.ToXmlStringValue(s3BucketDestination.Prefix)); } xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); } xmlWriter.WriteElementString("IsEnabled", "http://s3.amazonaws.com/doc/2006-03-01/", inventoryConfiguration.IsEnabled.ToString().ToLowerInvariant()); if (inventoryConfiguration.IsSetInventoryFilter()) { xmlWriter.WriteStartElement("Filter", "http://s3.amazonaws.com/doc/2006-03-01/"); inventoryConfiguration.InventoryFilter.InventoryFilterPredicate.Accept(new InventoryPredicateVisitor(xmlWriter)); xmlWriter.WriteEndElement(); } if (inventoryConfiguration.IsSetInventoryId()) { xmlWriter.WriteElementString("Id", "http://s3.amazonaws.com/doc/2006-03-01/", S3Transforms.ToXmlStringValue(inventoryConfiguration.InventoryId)); } if (inventoryConfiguration.IsSetIncludedObjectVersions()) { xmlWriter.WriteElementString("IncludedObjectVersions", "http://s3.amazonaws.com/doc/2006-03-01/", S3Transforms.ToXmlStringValue(ConstantClass.op_Implicit(inventoryConfiguration.IncludedObjectVersions))); } if (inventoryConfiguration.IsSetInventoryOptionalFields()) { xmlWriter.WriteStartElement("OptionalFields", "http://s3.amazonaws.com/doc/2006-03-01/"); foreach (InventoryOptionalField inventoryOptionalField in inventoryConfiguration.InventoryOptionalFields) { xmlWriter.WriteElementString("Field", "http://s3.amazonaws.com/doc/2006-03-01/", S3Transforms.ToXmlStringValue(ConstantClass.op_Implicit(inventoryOptionalField))); } xmlWriter.WriteEndElement(); } if (inventoryConfiguration.IsSetSchedule()) { xmlWriter.WriteStartElement("Schedule", "http://s3.amazonaws.com/doc/2006-03-01/"); InventorySchedule schedule = inventoryConfiguration.Schedule; if (schedule.IsFrequency()) { xmlWriter.WriteElementString("Frequency", "http://s3.amazonaws.com/doc/2006-03-01/", S3Transforms.ToXmlStringValue(ConstantClass.op_Implicit(schedule.Frequency))); } xmlWriter.WriteEndElement(); } } xmlWriter.WriteEndElement(); } } try { string text = stringWriter.ToString(); val.set_Content(Encoding.UTF8.GetBytes(text)); val.get_Headers()["Content-Type"] = "application/xml"; string value = AmazonS3Util.GenerateChecksumForContent(text, fBase64Encode: true); val.get_Headers()["Content-MD5"] = value; return(val); } catch (EncoderFallbackException ex) { throw new AmazonServiceException("Unable to marshall request to XML", (Exception)ex); } }