public PRQ_Requisition_Temp GetReq_temp_ItemByProductInfo(string EID, int barcode, Guid userId) { try { PRQ_Requisition_Temp aPRQ_Requisition_Temp = _context.PRQ_Requisition_Temp.Where(req => req.EID == EID && req.BarCode == barcode && req.EditUser == userId).FirstOrDefault <PRQ_Requisition_Temp>(); return(aPRQ_Requisition_Temp); } catch (Exception ex) { throw ex; } }
//protected void txtDate_TextChanged(object sender, EventArgs e) //{ // BindRequisitionNo(); //} protected void BtnSave_Click(object sender, EventArgs e) { try { Guid userId = ((SessionUser)Session["SessionUser"]).UserId; string pronductNameandBrand = ddlProduct.SelectedItem.ToString(); string[] values = pronductNameandBrand.Split('-'); string EID = txtEID.Text; string Barocode = ddlProduct.SelectedValue; string BarCode = ddlProduct.SelectedValue; string Quantity = txtQuantity.Text; string ReqDate = txtDate.Text; if (BarCode == "" || Quantity == "" || ReqDate == "" || ddlDepartment.SelectedValue == "0" || ddlEmployee.SelectedValue == "0") { return; } string OCODE = ((SessionUser)Session["SessionUser"]).OCode; string barCode = ddlProduct.SelectedValue.ToString(); var result1 = productBll.GetProductById(Convert.ToInt32(ddlProduct.SelectedValue)); double inputBalance = Convert.ToDouble(txtQuantity.Text); var details = productBll.GetProductBalanceByIdForReq(Convert.ToInt32(ddlProduct.SelectedValue)); var details2 = productBll.GetProductBalanceForRequisition(Convert.ToInt32(ddlProduct.SelectedValue)); double?reqQty = 0; double?balanceqty = 0; if (details2 != null) { reqQty = details2.PrqBalanceQuanity; } else { reqQty = 0; } if (details != null) { balanceqty = details.BalanceQuanity; } else { balanceqty = 0; } if (reqQty + inputBalance > balanceqty) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Stock Not Available!')", true); return; } if (int.Parse(txtQuantity.Text) <= 0) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Requisition quantity cannot be zero or negative!')", true); //lblMessage.Text = "<font color='red'>Sorry! Invalid data. Requisition quantity cannot be zero or negative. Please enter correct data</font>"; return; } if (BtnSave.Text == "Add") { Hashtable ht = new Hashtable(); //ht.Add("ReqNo", txtRequisitionNo.Text); ht.Add("ReqType", "Store"); ht.Add("CompanyCode", ""); ht.Add("DPT_CODE", ddlDepartment.SelectedValue); //ht.Add("DPT_CODE", hdnDEPT_CODE.Value); ht.Add("EID", ddlEmployee.SelectedValue); //ht.Add("EID", txtEID.Text); ht.Add("GroupId", ddlProductGroup.SelectedValue); ht.Add("BarCode", ddlProduct.SelectedValue); ht.Add("Qty", txtQuantity.Text); ht.Add("ReqDate", txtDate.Text); ht.Add("DesiredRcvDate", txtExpectedDate.Text); ht.Add("OCode", ((SessionUser)Session["SessionUser"]).OCode); ht.Add("RecomendBy", ""); // ht.Add("Program", ddlProgram.SelectedValue); ht.Add("Reason_Justification", ""); ht.Add("RequisitionFor", txtRequisitionFor.Text); ht.Add("Location", txtLocation.Text); ht.Add("Remarks", txtRemarks.Text); ht.Add("Supervisor_EID", hidReportingBossID.Value); ht.Add("EditUser", ((SessionUser)Session["SessionUser"]).UserId.ToString()); ht.Add("EditDate", DateTime.Now); PRQ_Requisition_Temp reqItem = aRequisionBll.GetReq_temp_ItemByProductInfo(txtEID.Text, Convert.ToInt16(ddlProduct.SelectedValue), userId); if (reqItem != null) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Item already in the list!')", true); return; } if (RequisionBll.PRQ_AddStoreRequisitionTemp(ht)) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Requisition for this item added successfully')", true); //lblMessage.Text = "<font color='green'>Requisition for this item added successfully!</font>"; //Load_Requisitions(txtRequisitionNo.Text); LoadRequisitions(txtEID.Text); ClearForm(); } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Error in adding requisition!')", true); //lblMessage.Text = "<font color='red'>Error in adding requisition! Please try again</font>"; } } if (BtnSave.Text == "Update") { DataTable dt = new DataTable(); //string ReqNo = txtRequisitionNo.Text; // string Barocde =ddlProduct.SelectedValue; dt = RequisionBll.GetBarCode(EID, BarCode); if (dt.Rows.Count > 0) { Hashtable ht = new Hashtable(); //ht.Add("ReqNo", txtRequisitionNo.Text); ht.Add("ReqType", "Store"); ht.Add("CompanyCode", ""); ht.Add("DPT_CODE", ddlDepartment.SelectedValue); //ht.Add("DPT_CODE", hdnDEPT_CODE.Value); ht.Add("EID", ddlEmployee.SelectedValue); //ht.Add("EID", txtEID.Text); //if (ddlProduct.SelectedValue == "") //{ // ht.Add("BarCode", HiddenField2.Value); //} //else //{ ht.Add("BarCode", BarCode); //} //if (txtQuantity.Text == "") //{ // ht.Add("Qty", HiddenField1.Value); //} //else //{ ht.Add("Qty", txtQuantity.Text); //} ht.Add("ReqDate", txtDate.Text); ht.Add("DesiredRcvDate", txtExpectedDate.Text); ht.Add("OCode", ((SessionUser)Session["SessionUser"]).OCode); ht.Add("RecomendBy", ""); ht.Add("RequisitionFor", txtRequisitionFor.Text); ht.Add("Location", txtLocation.Text); ht.Add("Remarks", txtRemarks.Text); ht.Add("Supervisor_EID", hidReportingBossID.Value); // ht.Add("Program", ddlProgram.SelectedValue); bool result = RequisionBll.updateStoreRequisitions(ht); if (result == false) { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Requisition for this item updated successfully')", true); //Load_Requisitions(txtRequisitionNo.Text); LoadRequisitions(txtEID.Text); ClearForm(); BtnSave.Text = "Add"; } else { ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Error in adding requisition!')", true); //lblMessage.Text = "<font color='red'>Error in adding requisition! Please try again</font>"; } } } } catch { } }
//internal int AddPurchaseRequisition_ForNewItem(string productName, string description) //{ // return aRequisitionDAL.AddPurchaseRequisition_ForNewItem(productName, description); //} public PRQ_Requisition_Temp GetReq_temp_ItemByProductInfo(string EID, int barcode, Guid userId) { PRQ_Requisition_Temp req = aRequisitionDAL.GetReq_temp_ItemByProductInfo(EID, barcode, userId); return(req); }