public static string[] ValidateQuantity(decimal enterdQuantity, int productid, int saleId) { string[] isfail = new string[2]; isfail[0] = "false"; isfail[1] = ""; IMS_TESTEntities context = new IMS_TESTEntities(); try { if (enterdQuantity != 0 && productid != 0) { if (companyId != 0 && saleId != 0) { SqlHelper helper = new SqlHelper(); var returnQuantity = context.GetReturnQuantity(saleId, Constants.Sale, productid, companyId).FirstOrDefault(); if (enterdQuantity > returnQuantity) { isfail[0] = "true"; isfail[1] = "Only " + returnQuantity + " can be return for the selected product."; return(isfail); } } } else { isfail[0] = "true"; isfail[1] = "Please select product or enter correct return quantity."; return(isfail); } //pass false as default if not true isfail[0] = "false"; } catch (Exception ex) { ErrorLog.saveerror(ex); } return(isfail); }
public static string[] ValidateQuantity(decimal enterdQuantity, int productid, int purchaseId) { string[] isfail = new string[2]; isfail[0] = "false"; isfail[1] = ""; IMS_TESTEntities context = new IMS_TESTEntities(); // int purchaseId = Convert.ToInt32(hdnPurchaseId.Value); try { if (enterdQuantity != 0 && productid != 0) { if (companyId != 0 && purchaseId != 0) { SqlHelper helper = new SqlHelper(); var stockQuantity = context.tbl_stock.Where(s => s.company_id == companyId && s.product_id == productid).FirstOrDefault(); var returnQuantity = context.GetReturnQuantity(purchaseId, Constants.Purchase, productid, companyId).FirstOrDefault(); if (enterdQuantity <= returnQuantity) { if (stockQuantity.qty < Convert.ToDecimal(enterdQuantity)) { isfail[0] = "true"; //lblcheckDoubleError.Visible = true; isfail[1] = "Insufficient stock quantity."; return(isfail); } } else { if (stockQuantity.qty <= returnQuantity) { isfail[0] = "true"; //lblcheckDoubleError.Visible = true; isfail[1] = "Only " + stockQuantity.qty + " can be return for the selected product, Since some of item sold."; return(isfail); } else { isfail[0] = "true"; //lblcheckDoubleError.Visible = true; isfail[1] = "Only " + returnQuantity + " can be return for the selected product."; return(isfail); } } } } else { isfail[0] = "true"; //lblcheckDoubleError.Visible = true; isfail[1] = "Please select product or enter correct return quantity."; return(isfail); } //pass false as default if not true isfail[0] = "false"; } catch (Exception ex) { ErrorLog.saveerror(ex); } return(isfail); }