public IHttpActionResult UpdateSubmittedVoucher(Report_ISO_Detail propertyNameList) { var result = otherISO.UpdateStatusVoucher(propertyNameList.VoucherID, propertyNameList.Status, propertyNameList.UserID, propertyNameList); JsonObject json = new JsonObject(); json["Success"] = result; return(Ok(json)); }
public bool UpdateStatusVoucher(string voucherID, string status, string userid, Report_ISO_Detail propertyNameList) { Console.WriteLine("DOCPlanAddDAL--DeletePlandAdd " + DateTime.Now); if (propertyNameList != null) { if (propertyNameList.Status != "X") { foreach (var item in propertyNameList.ListProperty) { string TotalBag = ""; if (item.PropertyValue.Contains("&")) { string[] PropertyArray = item.PropertyValue.Split('&'); for (int i = 0; i < PropertyArray.Length; i++) { if (i > 0) { TotalBag += " & "; } if (PropertyArray[i].ToString().Trim().Contains("-")) { string[] PropertyDetail = PropertyArray[i].Split('-'); string first_param = PropertyDetail[0].Trim(); string second_param = PropertyDetail[1].Trim(); decimal number_1 = Convert.ToDecimal(string.Concat(first_param.Substring(first_param.Length - 4, 4).Reverse().Skip(1).Reverse())); decimal number_2 = Convert.ToDecimal(string.Concat(second_param.Substring(second_param.Length - 4, 4).Reverse().Skip(1).Reverse())); Decimal result = Decimal.Subtract(number_1, number_2); TotalBag += (Math.Abs(result) + 1); } } } else { if (item.PropertyValue.Trim().Contains("-")) { string[] PropertyDetail = item.PropertyValue.Split('-'); string first_param = PropertyDetail[0].Trim(); string second_param = PropertyDetail[1].Trim(); decimal number_1 = Convert.ToDecimal(string.Concat(first_param.Substring(first_param.Length - 4, 4).Reverse().Skip(1).Reverse())); decimal number_2 = Convert.ToDecimal(string.Concat(second_param.Substring(second_param.Length - 4, 4).Reverse().Skip(1).Reverse())); Decimal result = Decimal.Subtract(number_1, number_2); TotalBag += (Math.Abs(result) + 1); } } if (string.IsNullOrEmpty(TotalBag)) { string updatecmd = @"Update Report_ISO_Detail SET [Range] = @Range WHERE VoucherID = @VoucherID AND PropertyName=@PropertyName "; acQC.ExecuteNonQuery(updatecmd, new object[] { item.PropertyValue, voucherID, item.PropertyName }); } else { string updatecmd = @"Update Report_ISO_Detail SET [Range] = @Range, [TotalBag] = @TotalBag WHERE VoucherID = @VoucherID AND PropertyName=@PropertyName "; acQC.ExecuteNonQuery(updatecmd, new object[] { item.PropertyValue, TotalBag, voucherID, item.PropertyName }); } } } } //核查是否能删除 string cmd = @"Update Report_ISO_Result SET Status = @Status, Stamp = GETDATE() WHERE VoucherID = @VoucherID; "; if (status == "P") { cmd += "EXEC RY_AddResults_To_ISOVoucher '" + voucherID + "', @UserID"; } try { acQC.ExecuteNonQuery(cmd, new object[] { status, voucherID, userid }); } catch (Exception ex) { log.Error(ex); Console.WriteLine(ex.Message); throw ex; } return(true); }