Ejemplo n.º 1
0
        protected void createReq()
        {
            if (DropDownList_Level1.SelectedValue.Equals("_"))
            {
                Label_Status.Text      = "Please select one product category";
                Label_Status.ForeColor = System.Drawing.Color.Red;
                Label_Status.Visible   = true;

                Button_Submit_Req.Enabled           = true;
                Button_Submit_Next.Enabled          = true;
                Button_Submit_Extra_Prd_Srv.Enabled = true;
            }
            else
            {
                BackEndObjects.Requirement reqObj = new BackEndObjects.Requirement();
                BackEndObjects.Id          idGen  = new BackEndObjects.Id();
                // String reqId = idGen.getNewId(BackEndObjects.Id.ID_TYPE_REQR_STRING);

                String reqId = "";
                if (Session[SessionFactory.CREATE_REQ_REQR_ID] == null)
                {
                    reqId = idGen.getNewId(BackEndObjects.Id.ID_TYPE_REQR_STRING);
                    Session[SessionFactory.CREATE_REQ_REQR_ID] = reqId; //store the newly created RFQ id in the session
                }
                if (!TextBox_Spec.Text.Equals(""))
                {
                    getAddintionalProdSrvList();
                    TextBox_Spec.Text = "";
                }

                ArrayList reqrSpecObjList = (ArrayList)Session[SessionFactory.CREATE_REQ_SELECTED_REQR_SPEC_MAP];

                //Set the requirement id for all the requirement spec objects
                //if(reqrSpecObjList!=null)
                //for(int i=0;i<reqrSpecObjList.Count;i++)
                //((BackEndObjects.Requirement_Spec)reqrSpecObjList[i]).setReqId(reqId);
                reqObj.setReqSpecs(reqrSpecObjList);
                //This setter method makes sure to add req id to all associated requirement spec objects if missing.
                reqObj.setReqId(reqId);
                reqObj.setCreatedUsr(User.Identity.Name);
                reqObj.setActiveStat(BackEndObjects.Requirement.REQ_ACTIVE_STAT_ACTIVE);
                reqObj.setDueDate(TextBox_Within_Date.Text);

                //Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()
                //reqObj.setEntityId(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());
                //Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()
                reqObj.setEntityId(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString());

                String localId = (!DropDownList_Locality.SelectedValue.Equals("_") && !DropDownList_Locality.SelectedValue.Equals("") ?
                                  DropDownList_Locality.SelectedValue : (!DropDownList_City.SelectedValue.Equals("_") && !DropDownList_City.SelectedValue.Equals("") ?
                                                                         DropDownList_City.SelectedValue : (!DropDownList_State.SelectedValue.Equals("_") && !DropDownList_State.SelectedValue.Equals("") ?
                                                                                                            DropDownList_State.SelectedValue : (!DropDownList_Country.SelectedValue.Equals("_") && !DropDownList_Country.SelectedValue.Equals("") ?
                                                                                                                                                DropDownList_Country.SelectedValue : ""))));

                reqObj.setLocalId(localId);
                reqObj.setReqName(TextBox_Reqr_Name.Text);

                reqObj.setSubmitDate(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                reqObj.setReqName(TextBox_Reqr_Name.Text);
                reqObj.setCurrency(DropDownList_Curr.SelectedValue);

                Dictionary <String, String> reqSpecUniqnessValidation = new Dictionary <string, string>();

                if (reqrSpecObjList != null)
                {
                    for (int i = 0; i < reqrSpecObjList.Count; i++)
                    {
                        BackEndObjects.Requirement_Spec reqrSpecObj = (BackEndObjects.Requirement_Spec)reqrSpecObjList[i];
                        if (reqSpecUniqnessValidation.ContainsKey(reqrSpecObj.getProdCatId() + ":" + reqrSpecObj.getFeatId()))
                        {
                            reqrSpecObjList.RemoveAt(i);//Remove the current requirement spec object from the list - otherwise it will cause exception at DB layer while inserting
                        }
                        else
                        {
                            reqSpecUniqnessValidation.Add(reqrSpecObj.getProdCatId() + ":" + reqrSpecObj.getFeatId(), "");
                            if (reqrSpecObj.getFileStream() != null)
                            {
                                reqrSpecObj.setImgPathInFileStore(reqObj.getEntityId());
                            }
                        }
                    }
                }

                BackEndObjects.RequirementProdServQnty reqProdSrvObj = new BackEndObjects.RequirementProdServQnty();
                reqProdSrvObj.setRequirementId(reqObj.getReqId());
                reqProdSrvObj.setProdCatId(Session[SessionFactory.CREATE_REQR_SELECTED_PRODUCT_CAT].ToString());
                reqProdSrvObj.setFromPrice(TextBox_Price_Range_From.Text);
                reqProdSrvObj.setFromQnty(float.Parse(TextBox_Prod_Qnty_From.Text));
                reqProdSrvObj.setMsrmntUnit(DropDownList_Unit_Of_Msrmnt.SelectedValue);
                reqProdSrvObj.setToPrice(TextBox_Price_Range_To.Text);
                reqProdSrvObj.setToQnty(float.Parse(TextBoxrod_Qnty_To.Text));

                ArrayList prodSrvQntyList = (ArrayList)Session[SessionFactory.CREATE_REQ_PROD_SRV_QNTY_LIST];

                if (prodSrvQntyList == null)
                {
                    prodSrvQntyList = new ArrayList();
                }

                //Ensure that all objects in the arraylist has an associated rfqid
                for (int i = 0; i < prodSrvQntyList.Count; i++)
                {
                    BackEndObjects.RequirementProdServQnty temp = (RequirementProdServQnty)prodSrvQntyList[i];
                    if (temp.getRequirementId() == null || temp.getRequirementId().Equals(""))
                    {
                        temp.setRequirementId(reqObj.getReqId());
                    }
                }

                prodSrvQntyList.Add(reqProdSrvObj);
                reqObj.setReqProdSrvQnty(prodSrvQntyList);

                ActionLibrary.PurchaseActions._createRequirements cR = new ActionLibrary.PurchaseActions._createRequirements();
                try
                {
                    cR.createNewRequirement(reqObj);
                    Label_Status.Text      = "Requirement created successfully";
                    Label_Status.ForeColor = System.Drawing.Color.Green;
                    Label_Status.Visible   = true;
                    //Refresh the parent grid
                    DataTable dt = (DataTable)Session[SessionFactory.ALL_PURCHASE_ALL_REQUIREMENT_GRID_DATA];
                    Dictionary <String, Currency> allCurrList = (Dictionary <String, Currency>)Session[SessionFactory.CURRENCY_LIST];

                    dt.Rows.Add();
                    int         i  = dt.Rows.Count - 1;
                    DateUtility dU = new DateUtility();

                    dt.Rows[i]["Hidden"]           = reqObj.getReqId();
                    dt.Rows[i]["Requirement Name"] = reqObj.getReqName();
                    dt.Rows[i]["curr"]             = allCurrList.ContainsKey(reqObj.getCurrency()) ?
                                                     allCurrList[reqObj.getCurrency()].getCurrencyName() : "";
                    dt.Rows[i]["Submit Date"]       = reqObj.getSubmitDate();
                    dt.Rows[i]["Submit Date Ticks"] = Convert.ToDateTime(reqObj.getSubmitDate()).Ticks;
                    dt.Rows[i]["Due Date"]          = dU.getConvertedDateWoTime(reqObj.getDueDate());
                    dt.Rows[i]["Due Date Ticks"]    = reqObj.getDueDate() != null && !reqObj.getDueDate().Equals("")?
                                                      Convert.ToDateTime(dt.Rows[i]["Due Date"]).Ticks:0;
                    dt.Rows[i]["Created By"] = reqObj.getCratedUsr();
                    dt.Rows[i]["Active?"]    = reqObj.getActiveStat();

                    dt.DefaultView.Sort = "Submit Date Ticks" + " " + "DESC";
                    Session[SessionFactory.ALL_PURCHASE_ALL_REQUIREMENT_GRID_DATA] = dt.DefaultView.ToTable();

                    ScriptManager.RegisterStartupScript(this, typeof(string), "RefreshReqGrid", "RefreshParent();", true);
                }
                catch (Exception ex)
                {
                    Label_Status.Text      = "Requirement creation failed";
                    Label_Status.ForeColor = System.Drawing.Color.Red;
                    Label_Status.Visible   = true;
                }
                finally
                {
                    Session.Remove(SessionFactory.CREATE_REQ_SELECTED_REQR_SPEC_MAP);
                    Session.Remove(SessionFactory.CREATE_REQ_REQR_ID);
                    Session.Remove(SessionFactory.CREATE_RFQ_PROD_SRV_QNTY_LIST);
                }
            }
        }
Ejemplo n.º 2
0
        protected void Button_Clone_Click(object sender, EventArgs e)
        {
            String contextName = Request.QueryString.GetValues("context")[0];
            String contextId   = Request.QueryString.GetValues("contextId1")[0];

            switch (contextName)
            {
            case "requirement":
                BackEndObjects.Requirement reqObj = BackEndObjects.Requirement.getRequirementbyIdDB(contextId);
                reqObj.setReqName(TextBox_Name.Text);
                reqObj.setReqId(new Id().getNewId(BackEndObjects.Id.ID_TYPE_REQR_STRING));
                reqObj.setSubmitDate(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

                ArrayList reqSpecLists = reqObj.getReqSpecs();
                for (int i = 0; i < reqSpecLists.Count; i++)
                {
                    BackEndObjects.Requirement_Spec reqSpecObj = (BackEndObjects.Requirement_Spec)reqSpecLists[i];
                    reqSpecObj.setReqId(reqObj.getReqId());
                    reqSpecObj.setImgPath("");
                }
                reqObj.setReqSpecs(reqSpecLists);

                ArrayList reqQntyList = reqObj.getReqProdSrvQnty();
                for (int i = 0; i < reqQntyList.Count; i++)
                {
                    BackEndObjects.RequirementProdServQnty reqQntyObj = (BackEndObjects.RequirementProdServQnty)reqQntyList[i];
                    reqQntyObj.setRequirementId(reqObj.getReqId());
                }
                reqObj.setReqProdSrvQnty(reqQntyList);

                try
                {
                    BackEndObjects.Requirement.insertRequirementDB(reqObj);
                    Label_Clone_Stat.Visible   = true;
                    Label_Clone_Stat.ForeColor = System.Drawing.Color.Green;
                    Label_Clone_Stat.Text      = "Cloning Successful. But no existing image or document will be copied.";
                }
                catch (Exception ex)
                {
                    Label_Clone_Stat.Visible   = true;
                    Label_Clone_Stat.ForeColor = System.Drawing.Color.Red;
                    Label_Clone_Stat.Text      = "Cloning Failed";
                }
                break;

            case "rfq":
                BackEndObjects.RFQDetails rfqObj = BackEndObjects.RFQDetails.getRFQDetailsbyIdDB(contextId);

                ArrayList rfqSpecList = BackEndObjects.RFQProductServiceDetails.getAllProductServiceDetailsbyRFQIdDB(rfqObj.getRFQId());
                ArrayList rfqQntyList = BackEndObjects.RFQProdServQnty.getRFQProductServiceQuantityforRFIdDB(rfqObj.getRFQId());

                rfqObj.setRFQName(TextBox_Name.Text);
                rfqObj.setSubmitDate(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                rfqObj.setRFQId(new Id().getNewId(Id.ID_TYPE_RFQ_STRING));
                rfqObj.setReqId("");                                                    //Remove tagged requirements
                rfqObj.setNDADocPath("");
                rfqObj.setActiveStat(BackEndObjects.RFQDetails.RFQ_ACTIVE_STAT_ACTIVE); //Overwrite the active status to active

                for (int i = 0; i < rfqSpecList.Count; i++)
                {
                    BackEndObjects.RFQProductServiceDetails rfqSpecObj = (BackEndObjects.RFQProductServiceDetails)rfqSpecList[i];
                    rfqSpecObj.setRFQId(rfqObj.getRFQId());
                    rfqSpecObj.setImgPath("");
                }
                rfqObj.setRFQProdServList(rfqSpecList);
                for (int i = 0; i < rfqQntyList.Count; i++)
                {
                    BackEndObjects.RFQProdServQnty rfqQntyObj = (BackEndObjects.RFQProdServQnty)rfqQntyList[i];
                    rfqQntyObj.setRFQId(rfqObj.getRFQId());
                }
                rfqObj.setRFQProdServQntyList(rfqQntyList);

                //Get the approval status
                int rfqLevel = BackEndObjects.MainBusinessEntity.
                               getMainBusinessEntitybyIdwithLessDetailsDB(Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()).getRfqApprovalLevel();
                if (rfqLevel > 0)
                {
                    String reportingToUser = BackEndObjects.userDetails.
                                             getUserDetailsbyIdDB(User.Identity.Name, Session[SessionFactory.MAIN_BUSINESS_ENTITY_ID_STRING].ToString()).getReportsTo();
                    rfqObj.setApprovalStat(reportingToUser);
                }
                else
                {
                    rfqObj.setApprovalStat(RFQDetails.RFQ_APPROVAL_STAT_APPROVED);
                }


                try
                {
                    BackEndObjects.RFQDetails.insertRFQDetailsDB(rfqObj);
                    Label_Clone_Stat.Visible   = true;
                    Label_Clone_Stat.ForeColor = System.Drawing.Color.Green;
                    Label_Clone_Stat.Text      = "Cloning Successful. But no existing image or document will be copied.Also approvals will be required as rule set in Administration->WorkFlow->RFQ Rules";
                }
                catch (Exception ex)
                {
                    Label_Clone_Stat.Visible   = true;
                    Label_Clone_Stat.ForeColor = System.Drawing.Color.Red;
                    Label_Clone_Stat.Text      = "Cloning Failed";
                }
                break;

            case "lead": createLead(contextId, new Id().getNewId(BackEndObjects.Id.ID_TYPE_RFQ_STRING), false);
                break;

            case "Potn":
                createLead(contextId, new Id().getNewId(BackEndObjects.Id.ID_TYPE_RFQ_STRING), true);

                break;
            }
        }