Beispiel #1
0
    /// <summary>
    /// Sent for Approval
    /// </summary>
    public void OnStsSaved(object s, EventArgs e)
    {
        try
        {
            TechnicalBAL objTechBAL    = new TechnicalBAL();
            string       QuotationCode = "";
            string       SupplierCode  = "";

            decimal Supp_Total_Amount = 0;
            decimal approvedAmount    = 0;
            dicTotalAmount.Clear();

            DataTable dtQuotationList = new DataTable();
            dtQuotationList.Columns.Add("Qtncode");
            dtQuotationList.Columns.Add("amount");

            CheckBox Chk = new CheckBox();
            foreach (GridViewRow gr in Grid_RqsnDtl.Rows)
            {
                Chk = (CheckBox)gr.FindControl("Chk_Item");

                if (Chk.Checked)
                {
                    Label lbl_Qnty = (Label)gr.FindControl("lbl_TotalPrice");
                    approvedAmount = Convert.ToDecimal(lbl_Qnty.Text) + approvedAmount;
                }
            }


            approvedAmount = approvedAmount + Convert.ToDecimal(hdfOrderAmounts.Value);



            SupplierCode  = hdfSupplierBeingApproved.Value;
            QuotationCode = hdfQTNCode.Value;


            Supp_Total_Amount = UDFLib.ConvertToDecimal(lbl_TotalAmount.Text);

            DataRow dtrow = dtQuotationList.NewRow();
            dtrow[0] = QuotationCode;
            dtrow[1] = dicTotalAmount[QuotationCode].ToString();
            dtQuotationList.Rows.Add(dtrow);

            // first send for approval
            int stsEntry = objTechBAL.InsertUserApprovalEntries(Requisitioncode, Document_Code, Vessel_Code, User, ucApprovalUser1.ApproverID, 0, 0, "", ucApprovalUser1.Remark, dtQuotationList);

            // save the approval
            objTechBAL.InsertUserApprovalEntries(Requisitioncode, Document_Code, Vessel_Code, User, User, Supp_Total_Amount, approvedAmount, "0", txtComment.Text.Trim(), dtQuotationList);
            String msg1 = String.Format("alert('Sent successfully.'); RefreshPendingDetails();window.close();");
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msgSENT", msg1, true);
        }
        catch (Exception ex)
        {
            UDFLib.WriteExceptionLog(ex);
        }
    }
Beispiel #2
0
    protected void OnStsSavedSentToApprover(object s, EventArgs e)
    {
        try
        {
            TechnicalBAL objpurc    = new TechnicalBAL();
            TechnicalBAL objTechBAL = new TechnicalBAL();

            //qtnbased
            DataTable dtQuotations    = BLL_PURC_Common.PURC_GET_Quotation_ByReqsnCode(Requisitioncode);
            DataTable dtQuotationList = new DataTable();
            dtQuotationList.Columns.Add("Qtncode");
            dtQuotationList.Columns.Add("amount");

            foreach (DataRow dr in dtQuotations.Rows)
            {
                if (dr["active_PO"].ToString() == "0") // for those POs have been cancelled(means active_PO is zero)
                {
                    DataRow dtrow = dtQuotationList.NewRow();
                    dtrow[0] = dr["QUOTATION_CODE"].ToString();
                    dtrow[1] = "0";
                    dtQuotationList.Rows.Add(dtrow);
                }
            }

            // save the requested qty into order qty and order qty column on grid will be bibnded to order qty (change so store the updated qty by supp at the time of eval.) { this functionality has been implemented at rfq send stage}
            // code to update the order qty have been commented ,this is used to save bgt code only.

            BLL_PURC_Common.Update_OrderQty_From_ReqstQty(Requisitioncode, Document_Code, ddlBGTCodeToSuppdt.SelectedValue);

            int stsEntry = objTechBAL.InsertUserApprovalEntries(Requisitioncode, Document_Code, Vessel_Code, User, ucApprovalUserToSuppdt.ApproverID, 0, 0, "", ucApprovalUserToSuppdt.Remark, dtQuotationList);
            if (stsEntry > 0)
            {
                // dtQuotationList is passing but not using in sp ,all quotation will be set as senttosuppdt as true for this reqsn
                int res = objpurc.PURC_Update_SentToSupdt(0, 0, Requisitioncode, int.Parse(User), ucApprovalUserToSuppdt.Remark, dtQuotationList);

                if (res > 0)
                {
                    BLL_PURC_Purchase objPurc = new BLL_PURC_Purchase();
                    //Requisition stage status update
                    objPurc.InsertRequisitionStageStatus(Requisitioncode, Vessel_Code, Document_Code, "QEV", " ", Convert.ToInt32(User), dtQuotationList);
                    BLL_PURC_Common.INS_Remarks(Document_Code, Convert.ToInt32(User), ucApprovalUserToSuppdt.Remark, 302);

                    String msg = String.Format("alert('Sent successfully'); RefreshPendingDetails();window.close();");
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg", msg, true);
                }
            }
        }
        catch (Exception ex)
        {
            UDFLib.WriteExceptionLog(ex);
        }
    }
Beispiel #3
0
    /// <summary>
    /// Show Approve Popup
    /// </summary>
    protected void btnApprove_Click(object sender, EventArgs e)
    {
        bool IsFinalAproved = false;

        try
        {
            string QuotationCode = "";
            string SupplierCode  = "";

            DataTable dtQuotationList_ForTopApprover = new DataTable();
            dtQuotationList_ForTopApprover.Columns.Add("Qtncode");
            dtQuotationList_ForTopApprover.Columns.Add("amount");

            DataTable dtQuotationList = new DataTable();
            dtQuotationList.Columns.Add("Qtncode");
            dtQuotationList.Columns.Add("amount");

            DataTable dtBudgetCode = new DataTable();
            dtBudgetCode.Columns.Add("Qtncode");
            dtBudgetCode.Columns.Add("amount");
            TechnicalBAL objTechBAL = new TechnicalBAL();

            string[] Attchment = new string[10];


            // check for provision's approval limit for items
            bool isProvisionLimitsts = isProvisionLimitExceeding();


            //Get Approval Amount

            BLL_PURC_Purchase objApproval = new BLL_PURC_Purchase();
            DataTable         dtApproval  = objApproval.Get_Approval_Limit(Convert.ToInt32(User), ViewState["Dept_Code"].ToString());
            if (dtApproval.Rows.Count < 1)
            {
                String msgApp = String.Format("alert('Approval limit does not exist for you.Please contact admin.');RefreshPendingDetails();window.close();");
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg99011a", msgApp, true);
                //divApprove.Visible = false;
                String msgmodal = String.Format("hideModal('divApprove');");
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msgonFinalmodalhide", msgmodal, true);
                return;
            }

            decimal dblPOAprLimitAmt = decimal.Parse(dtApproval.Rows[0]["Approval_Limit"].ToString());
            if (dblPOAprLimitAmt < 1)
            {
                String msgApp = String.Format("alert('Approval limit does not exist for you.Please contact admin.');RefreshPendingDetails() ;window.close();");
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg660081g", msgApp, true);
                String msgmodal = String.Format("hideModal('divApprove');");
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msgonFinalmodalhide", msgmodal, true);
                return;
            }

            TechnicalBAL objtechBAL = new TechnicalBAL();
            objtechBAL.Update_ReqsnType(Requisitioncode, UDFLib.ConvertToInteger(ddlReqsnType.SelectedValue), "", UDFLib.ConvertToInteger(User));

            decimal Supp_Total_Amount = 0;
            decimal approvedAmount    = 0;
            dicTotalAmount.Clear();

            CheckBox Chk = new CheckBox();
            foreach (GridViewRow gr in Grid_RqsnDtl.Rows)
            {
                Chk = (CheckBox)gr.FindControl("Chk_Item");

                if (Chk.Checked)
                {
                    Label lbl_Qnty = (Label)gr.FindControl("lbl_TotalPrice");
                    approvedAmount = Convert.ToDecimal(lbl_Qnty.Text) + approvedAmount;
                }
            }


            // add the orderedamount from existing POs in approved amount(amount going to be approved)
            approvedAmount = approvedAmount + Convert.ToDecimal(hdfOrderAmounts.Value);

            Supp_Total_Amount = decimal.Parse(hdfMaxQuotedAmount.Value);


            SupplierCode  = hdfSupplierBeingApproved.Value;
            QuotationCode = hdfQTNCode.Value;

            BLL_PURC_Purchase objTechService = new BLL_PURC_Purchase();

            string retval = "TRUE";
            if (hdnBudgetCode.Value.ToString() == "1")
            {
                DataRow dtrow = dtBudgetCode.NewRow();
                dtrow[0] = QuotationCode;
                dtrow[1] = dicTotalAmount[QuotationCode].ToString();
                dtBudgetCode.Rows.Add(dtrow);
                retval = objTechService.Check_Update_BudgetCode(Requisitioncode, Vessel_Code, ddlBudgetCode.SelectedValue, dtBudgetCode);
            }

            if (retval == "TRUE")
            {
                if (Supp_Total_Amount > dblPOAprLimitAmt || approvedAmount > dblPOAprLimitAmt)// supplier code is zero in this case
                {
                    objApproval.POApproving(Requisitioncode, QuotationCode, "0", User, "", Vessel_Code, ddlBudgetCode.SelectedValue.ToString());

                    // store the qtn code and supp amount for top approver
                    DataRow dtrow = dtQuotationList_ForTopApprover.NewRow();
                    dtrow[0] = QuotationCode;
                    dtrow[1] = dicTotalAmount[QuotationCode].ToString();
                    dtQuotationList_ForTopApprover.Rows.Add(dtrow);
                }

                else if (Supp_Total_Amount <= dblPOAprLimitAmt && approvedAmount <= dblPOAprLimitAmt && (isProvisionLimitsts == false))//The actual approval
                {
                    //qtnbased

                    DataRow dtrow = dtQuotationList.NewRow();
                    dtrow[0] = QuotationCode;
                    dtrow[1] = dicTotalAmount[QuotationCode].ToString();
                    dtQuotationList.Rows.Add(dtrow);

                    /// begin insert the records for final PO
                    DataTable dtReqInfo = new DataTable();
                    dtReqInfo = objTechService.SelectSupplierToSendOrderEval(Requisitioncode, Vessel_Code, QuotationCode);
                    SavePurchasedOrder(dtReqInfo.DefaultView.ToTable());

                    objTechService.POApproving(Requisitioncode, QuotationCode, SupplierCode, User, txtComment.Text, Vessel_Code, ddlBudgetCode.SelectedValue.ToString());


                    IsFinalAproved = true;
                }
            }
            else
            {
                //btnRequestAmount.Visible = true;
                String msg1 = String.Format("alert('A.Total Approval amount is greater than Budget limit,Please request for increase Budget limit.');");
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg", msg1, true);
                String msgmodal = String.Format("showModal('divApprove');");
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msgonFinalmodal", msgmodal, true);
            }
            //}
            // }

            if (IsFinalAproved)
            {
                //Requisition stage status update
                // BLL_PURC_Purchase objTechService = new BLL_PURC_Purchase();
                //Check Budget Code and Update
                retval = "TRUE";
                if (hdnBudgetCode.Value.ToString() == "1")
                {
                    retval = objTechService.Check_Update_BudgetCode(Requisitioncode, Vessel_Code, ddlBudgetCode.SelectedValue, dtBudgetCode);
                }

                if (retval == "TRUE")
                {
                    //btnRequestAmount.Visible = false;
                    // SAVE APPROVAL
                    objTechBAL.InsertUserApprovalEntries(Requisitioncode, Document_Code, Vessel_Code, User, User, Supp_Total_Amount, approvedAmount, "0", txtComment.Text.Trim(), dtQuotationList);

                    BLL_PURC_Common.INS_Remarks(Document_Code, Convert.ToInt32(User), txtComment.Text.Trim(), 303);
                    objTechService.InsertRequisitionStageStatus(Requisitioncode, Vessel_Code, Document_Code, "RPO", " ", Convert.ToInt32(User), dtQuotationList);

                    String msg1 = String.Format("alert('Approved successfully.'); RefreshPendingDetails(); window.close();");
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg", msg1, true);
                    return;
                }
                else
                {
                    //btnRequestAmount.Visible = true;
                    String msg1 = String.Format("alert('B.Total Approval amount is greater than Budget limit,Please request for increase Budget limit.');");
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg", msg1, true);
                    String msgmodal = String.Format("showModal('divApprove');");
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msgonFinalmodal", msgmodal, true);
                }
            }

            else
            {
                if (!isProvisionLimitsts)
                {
                    //check if only one approver is left then send him directly instead of prompting the current user to send and save the current approver's approval.
                    //  BLL_PURC_Purchase objTechService = new BLL_PURC_Purchase();
                    retval = "TRUE";
                    if (hdnBudgetCode.Value.ToString() == "1")
                    {
                        retval = objTechService.Check_Update_BudgetCode(Requisitioncode, Vessel_Code, ddlBudgetCode.SelectedValue, dtBudgetCode);
                    }

                    if (retval == "TRUE")
                    {
                        //btnRequestAmount.Visible = false;
                        int ApproverCount = BLL_PURC_Common.CheckHierarchy_SendForApproval(Requisitioncode, Document_Code, Convert.ToInt32(Vessel_Code), User, Supp_Total_Amount, dblPOAprLimitAmt, dtQuotationList_ForTopApprover);
                        if (ApproverCount == 1)
                        {
                            BLL_PURC_Common.INS_Remarks(Document_Code, Convert.ToInt32(User), txtComment.Text.Trim(), 303);
                            String msg = String.Format("alert('Approved successfully but  total Approval amount is greater than your approval limit ,this Requisition is now being sent to your supirior for his approval.'); RefreshPendingDetails();window.close();");
                            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg16", msg, true);
                        }
                        else if (ApproverCount > 1)
                        {
                            BLL_PURC_Common.INS_Remarks(Document_Code, Convert.ToInt32(User), txtComment.Text.Trim(), 303);
                            String msg1 = String.Format("alert('Approved successfully but  total Approval amount is greater than your approval limit ,this Requisition is now being sent to your supirior for his approval ');");
                            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg", msg1, true);
                            ucApprovalUser1.ReqsnCode = Requisitioncode;


                            ucApprovalUser1.FillUser();
                            dvSendForApproval.Visible = true;
                        }
                        else if (ApproverCount == 0)
                        {
                            BLL_PURC_Common.INS_Remarks(Document_Code, Convert.ToInt32(User), txtComment.Text.Trim(), 303);
                            String msg1 = String.Format("alert('Total Approval amount is greater than your approval limit and no approver found for the amount " + Supp_Total_Amount + " . Please contact your manager.' );");
                            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msgCt0", msg1, true);
                        }
                        String msgmoda12l = String.Format("hideModal('divApprove');");
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msgonFinalmodalhide", msgmoda12l, true);
                    }
                    else
                    {
                        //btnRequestAmount.Visible = true;
                        String msg1 = String.Format("alert('C.Total Approval amount is greater than Budget limit,Please request for increase Budget limit.');");
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msg", msg1, true);
                        String msgmodal = String.Format("showModal('divApprove');");
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msgonFinalmodal", msgmodal, true);
                    }
                }
            }



            //divApprove.Visible = false;
            return;
        }
        catch (Exception ex)
        {
            UDFLib.WriteExceptionLog(ex);
        }
    }
    protected void OnStsSaved(object s, EventArgs e)
    {
        try
        {
            TechnicalBAL objTechBAL = new TechnicalBAL();
            TechnicalBAL objpurc    = new TechnicalBAL();

            // reqsncode will be set to "" in uc after update
            string[] prm = HiddenFieldSuppdtRemark.Value.Split(new char[] { ',' });

            DataTable dtQuotations = BLL_PURC_Common.PURC_GET_Quotation_ByReqsnCode(prm[2].ToString());

            DataTable dtQuotationList = new DataTable();
            dtQuotationList.Columns.Add("Qtncode");
            dtQuotationList.Columns.Add("amount");

            foreach (DataRow dr in dtQuotations.Rows)
            {
                if (dr["active_PO"].ToString() == "0") // for those POs have been cancelled(means active_PO is zero)
                {
                    DataRow dtrow = dtQuotationList.NewRow();
                    dtrow[0] = dr["QUOTATION_CODE"].ToString();
                    dtrow[1] = "0";
                    dtQuotationList.Rows.Add(dtrow);
                }
            }
            // save the requested qty into order qty and order qty column on grid will be binded to order qty (change so store the updated qty by supp at the time of eval.) { this functionality has been implemented at rfq send stage}
            // code to update the order qty have been commented ,this is used to save bgt code only.
            //
            //BLL_PURC_Purchase objTechService = new BLL_PURC_Purchase();
            //int retval = 0;
            //if (Session["BudgetDetails"] != null)
            //{
            //    retval = objTechService.Check_Update_BudgetCode(prm[2].ToString(), prm[3].ToString(), ddlBudgetCode.SelectedValue);
            //}
            //else
            //{
            BLL_PURC_Common.Update_OrderQty_From_ReqstQty(prm[2].ToString(), prm[3].ToString(), ddlBudgetCode.SelectedValue);
            //}

            //qtnbased
            int stsEntry = objTechBAL.InsertUserApprovalEntries(prm[2].ToString(), prm[3].ToString(), prm[4].ToString(), Session["userid"].ToString(), ucApprovalUser1.ApproverID, 0, 0, "", ucApprovalUser1.Remark, dtQuotationList);
            if (stsEntry > 0)
            {
                // dtQuotationList is passing but not using in sp ,all quotation will be set as senttosuppdt as true for this reqsn
                int res = objpurc.PURC_Update_SentToSupdt(int.Parse(prm[0]), int.Parse(prm[1]), prm[2].ToString(), int.Parse(Session["USERID"].ToString()), ucApprovalUser1.Remark, dtQuotationList);


                if (res > 0)
                {
                    BLL_PURC_Purchase objPurc = new BLL_PURC_Purchase();
                    //Requisition stage status update and remark
                    objPurc.InsertRequisitionStageStatus(prm[2].ToString(), prm[4].ToString(), prm[3].ToString(), "QEV", " ", Convert.ToInt32(Session["USERID"]), dtQuotationList);
                    BLL_PURC_Common.INS_Remarks(prm[3].ToString(), Convert.ToInt32(Session["userid"].ToString()), ucApprovalUser1.Remark, 302);

                    divOnHold.Visible    = false;
                    divReqStages.Visible = false;

                    ucCustomPagerItems.isCountRecord = 1;
                    BindData();
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }