예제 #1
0
        protected void btnAllOfferReceieved_Click(object sender, EventArgs e)
        {
            LinkButton btn = (LinkButton)sender;

            objWorkFlow           = new WorkFlow();
            objWorkFlow.WFID      = Convert.ToInt32(btn.CommandArgument);
            objWorkFlow.UserId    = Request.QueryString["u"];
            objWorkFlow.WF_Status = "All Offer Received";
            int res = objWorkFlow.UpdateWF_Status();

            objWorkFlow.UpdateWF_StatusInBAANTable(); // Dump Preorder Data TO BAAN table change 25/08/2018 sagar
            if (res > 0)
            {
                InsertPreHistory(Convert.ToInt32(btn.CommandArgument), "All Offer Received");
                // GetData();
                //ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Status Changed to All Offer Received');", true);
            }

            else
            {
                ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Some technical issue');", true);
            }

            DataTable dt12 = objWorkFlow.GetWFById();

            if (dt12.Rows.Count > 0)
            {
                foreach (DataRow dr12 in dt12.Rows)
                {
                    objWorkFlow.Project = dr12["Project"].ToString().Substring(0, 6);
                }
            }
            string    WFID      = objWorkFlow.WFID.ToString();
            string    PMDLDocNo = "";
            string    PMDLDocs  = "";
            DataTable dtPMDL    = objWorkFlow.GetMultiPMDL(WFID);

            if (dtPMDL.Rows.Count > 0)
            {
                foreach (DataRow dr in dtPMDL.Rows)
                {
                    objWorkFlow.PMDLdocDesc = dr["PMDLDocNo"].ToString();
                    DataTable dataTable = objWorkFlow.GetRaisedEnquiryDate();
                    if (dataTable.Rows.Count > 0)
                    {
                        objWorkFlow.ItemReference = (string)dataTable.Rows[0]["t_iref"];
                        string    Itemref_Typ  = objWorkFlow.GetItemRefType();
                        DataTable dtPMDLbyWFID = objWorkFlow.GetPMDLbyWFID();
                        if (dtPMDLbyWFID.Rows.Count > 0)
                        {
                            for (int i = 0; i < dtPMDLbyWFID.Rows.Count; i++)
                            {
                                if (i == 0)
                                {
                                    PMDLDocNo = "'" + dtPMDLbyWFID.Rows[0]["PMDLDocNo"].ToString() + "'";
                                }
                                else
                                {
                                    PMDLDocNo += ",'" + dtPMDLbyWFID.Rows[i]["PMDLDocNo"].ToString() + "'";
                                }
                            }
                        }
                        //  objWorkFlow.UpdateAllTechOfferReceived(); //earlier TechOfferReceieved percentage is to be set to 100 now logic change-
                        //change date - 14-09-2018

                        #region Progress Update of Offer Received Percentage on  All Offer Received button click

                        double nOfferReceiveDrawing_Count   = 0;
                        double nOfferReceivedDrawing_Weight = 0;

                        double nTotalOfferReceived_Count  = 0;
                        double nToatlOfferReceived_Weight = 0;

                        double percentageTechOfferReceivedDrawing_byCount  = 0;
                        double percentageTechOfferReceivedDrawing_byWeight = 0;

                        nTotalOfferReceived_Count  = objWorkFlow.GetTotalInquirySentCount();
                        nOfferReceiveDrawing_Count = objWorkFlow.GeTechOfferReceievedDrawingCount(PMDLDocNo);

                        nOfferReceivedDrawing_Weight = objWorkFlow.GetCuurentRFQ_OfferReceivedDrawingWeight(PMDLDocNo);
                        //objWorkFlow.GetTechOfferReceivedDrawingWeight();
                        nToatlOfferReceived_Weight = objWorkFlow.GetTotalDrawingWeight();
                        //objWorkFlow.GetTotalDrawingWeight();

                        if (nTotalOfferReceived_Count != 0)
                        {
                            percentageTechOfferReceivedDrawing_byCount = Math.Round((nOfferReceiveDrawing_Count / nTotalOfferReceived_Count) * 100, 4);
                        }

                        if (nToatlOfferReceived_Weight != 0)
                        {
                            percentageTechOfferReceivedDrawing_byWeight = Math.Round((nOfferReceivedDrawing_Weight / nToatlOfferReceived_Weight) * 100, 4);
                        }
                        objWorkFlow.WF_Status            = "All Offer Received";
                        objWorkFlow.BusinessObjectHandle = "CT_RFQOFFERECEIVED";
                        objWorkFlow.Parent_WFID          = objWorkFlow.WFID;
                        double percentage_byCount  = 0;
                        double percentage_byWeight = 0;

                        objWorkFlow.InsertIntoItemReferencewiseProgressTable(percentageTechOfferReceivedDrawing_byWeight, percentageTechOfferReceivedDrawing_byCount);
                        //DataTable dtPercentage = objWorkFlow.GetTechnoComNegotiationPercentagebyCount_Weight();
                        DataTable dtPercentage1 = objWorkFlow.GetPercentagebyCount_Weight();
                        if (dtPercentage1.Rows.Count > 0)
                        {
                            foreach (DataRow dr1 in dtPercentage1.Rows)
                            {
                                objWorkFlow.Project       = dr1["Project"].ToString();
                                objWorkFlow.ItemReference = dr1["ItemReference"].ToString();
                                //double percentage_byCount = Convert.ToDouble(dr1["CountPercentage"]);
                                //double percentage_byWeight = Convert.ToDouble(dr1["WeightPercentage"]);
                                percentage_byCount  += Convert.ToDouble(dr1["CountPercentage"]);
                                percentage_byWeight += Convert.ToDouble(dr1["WeightPercentage"]);
                            }
                        }

                        if (percentage_byCount < 100.00 && percentage_byWeight < 100.00)
                        {
                            if ((percentage_byCount >= percentage_byWeight))
                            {
                                // objWorkFlow.UpdateTechOfferReceivedDrawingpercentage(percentage_byCount);
                            }
                            else
                            {
                                if (Itemref_Typ == "4")// when item reference typ=="Self Engineered"
                                {
                                    // objWorkFlow.UpdateTechOfferReceivedDrawingpercentage(percentage_byWeight);
                                }
                                else
                                {
                                    // objWorkFlow.UpdateTechOfferReceivedDrawingpercentage(percentage_byCount);
                                }
                            }
                        }

                        else
                        {
                            if (percentage_byCount >= 100)
                            {
                                // objWorkFlow.UpdateTechOfferReceivedDrawingpercentage(100);
                            }
                            else
                            {
                                // objWorkFlow.UpdateTechOfferReceivedDrawingpercentage(percentage_byCount);
                            }
                        }
                        #endregion

                        #region Progress Update for Tecno Comm. Negotiation on All Offer Received Button Click

                        DataTable dtPMDLDoc = objWorkFlow.GetPMDLFromItemRef();
                        if (dtPMDLDoc.Rows.Count > 0)
                        {
                            for (int i = 0; i < dtPMDLDoc.Rows.Count; i++)
                            {
                                if (i == 0)
                                {
                                    PMDLDocs = "'" + dtPMDLDoc.Rows[0]["t_docn"].ToString() + "'";
                                }
                                else
                                {
                                    PMDLDocs += ",'" + dtPMDLDoc.Rows[i]["t_docn"].ToString() + "'";
                                }
                            }
                        }


                        double nTechnoComNegotiationDrawing_Count  = 0;
                        double nTechnoComNegotiationDrawing_Weight = 0;

                        double nTotalTechnoComNegotiation_Count  = 0;
                        double nTotalTechnoComNegotiation_Weight = 0;

                        double percentageTechnoComNegotiation_byCount = 0;
                        double percentageTechnoComNegotiatio_byWeight = 0;

                        // nTotalTechnoComNegotiation_Count = objWorkFlow.GetTotalChildRecordCount(PMDLDocNo);
                        nTotalTechnoComNegotiation_Count = objWorkFlow.AllOfferReceieved_ChildRecordCount(PMDLDocNo);
                        //3
                        nTechnoComNegotiationDrawing_Count = objWorkFlow.GetTechnoCommercialChildRecordCount(PMDLDocNo);
                        //objWorkFlow.GetCuurentRFQ_OfferReceivedDrawingWeight
                        nTechnoComNegotiationDrawing_Weight = objWorkFlow.GetCuurentRFQComNegotiation_OfferReceivedDrawingWeight(PMDLDocNo);
                        nTotalTechnoComNegotiation_Weight   = objWorkFlow.GetTotalDrawingWeight();

                        if (nTotalTechnoComNegotiation_Count != 0 && nTotalOfferReceived_Count != 0)
                        {
                            percentageTechnoComNegotiation_byCount = Math.Round((nTechnoComNegotiationDrawing_Count / nTotalTechnoComNegotiation_Count)
                                                                                * (nOfferReceiveDrawing_Count / nTotalOfferReceived_Count) * 100, 4);
                        }
                        if (nToatlOfferReceived_Weight != 0 && nTotalTechnoComNegotiation_Weight != 0)
                        {
                            // percentageTechnoComNegotiatio_byWeight = Math.Round((nTechnoComNegotiationDrawing_Weight / nTotalTechnoComNegotiation_Weight) * (nOfferReceivedDrawing_Weight / nToatlOfferReceived_Weight) * 100, 4);
                            percentageTechnoComNegotiatio_byWeight = Math.Round((nTechnoComNegotiationDrawing_Weight / nTotalTechnoComNegotiation_Weight) * (nTechnoComNegotiationDrawing_Count / nTotalTechnoComNegotiation_Count) * 100, 4);
                        }
                        objWorkFlow.Parent_WFID          = objWorkFlow.WFID;
                        objWorkFlow.BusinessObjectHandle = "CT_RFQCOMMERCIALFINALISED";
                        objWorkFlow.WF_Status            = "All Offer Received";

                        objWorkFlow.InsertIntoItemReferencewiseProgressTable(percentageTechnoComNegotiatio_byWeight, percentageTechnoComNegotiation_byCount);
                        //DataTable dtPercentage = objWorkFlow.GetTechnoComNegotiationPercentagebyCount_Weight();
                        DataTable dtPercentage         = objWorkFlow.GetPercentagebyCount_Weight();
                        double    percentage_byCount1  = 0;
                        double    percentage_byWeight1 = 0;

                        if (dtPercentage.Rows.Count > 0)
                        {
                            foreach (DataRow dr2 in dtPercentage.Rows)
                            {
                                objWorkFlow.Project       = dr2["Project"].ToString();
                                objWorkFlow.ItemReference = dr2["ItemReference"].ToString();
                                //double percentage_byCount1 = Convert.ToDouble(dr2["CountPercentage"]);
                                //double percentage_byWeight1 = Convert.ToDouble(dr2["WeightPercentage"]);
                                percentage_byCount1  += Convert.ToDouble(dr2["CountPercentage"]);
                                percentage_byWeight1 += Convert.ToDouble(dr2["WeightPercentage"]);
                            }
                        }

                        if (percentage_byCount1 < 100.00 && percentage_byWeight1 < 100.00)
                        {
                            if ((percentage_byCount1 >= percentage_byWeight1))
                            {
                                //  objWorkFlow.UpdateTechOfferReceivedDrawingpercentage(percentage_byCount1);
                            }
                            else
                            {
                                if (Itemref_Typ == "4")// when item reference typ=="Self Engineered"
                                {
                                    //  objWorkFlow.UpdateTechOfferReceivedDrawingpercentage(percentage_byWeight1);
                                }
                                else
                                {
                                    //  objWorkFlow.UpdateTechOfferReceivedDrawingpercentage(percentage_byCount1);
                                }
                            }
                        }

                        else
                        {
                            if (percentage_byCount1 >= 100)
                            {
                                // objWorkFlow.UpdateTechOfferReceivedDrawingpercentage(100);
                            }
                            else
                            {
                                //  objWorkFlow.UpdateTechOfferReceivedDrawingpercentage(percentage_byCount1);
                            }
                        }
                        //    }
                        //}
                        #endregion

                        // }
                        // }
                    }
                }
            }
            else
            {
            }

            GetData();
            ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Status Changed to All Offer Received');", true);
        }