Exemplo n.º 1
0
        public void BindValue()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["RequestID"]))
            {
                requestID = Request.QueryString["RequestID"].Trim();
            }



            CPT_ResourceDemand cPT_ResourceDemand = new CPT_ResourceDemand();

            cPT_ResourceDemand.RequestID = requestID;
            ResourceDemandBL resource = new ResourceDemandBL();



            CPT_ResourceDemand demand = new CPT_ResourceDemand();

            demand.RequestID = requestID;
            List <CPT_ResourceDemand> lst = resource.ViewResourceDemand(demand);

            reqID.Text        = lst[0].RequestID;
            salesStageDD.Text = lst[0].SalesStageID.ToString();
            accNameDD.Text    = lst[0].AccountID.ToString();
            proccName.Text    = lst[0].ProcessName;
            oppTypeDD.Text    = lst[0].OpportunityID.ToString();
            List <int> regionIDs = ResourceDemandBL.getRegionID(lst[0].AccountID);

            regionID = regionIDs[0];
            regionNameDD.Items.FindByValue(regionID.ToString()).Selected = true;
            StatusMasterID.Text = lst[0].StatusMasterID.ToString();

            ResourceDetailsBL.ViewResourceDetails(rptResourceDetails, requestID);
        }
Exemplo n.º 2
0
        protected void Add_Resource_Demand(object sender, EventArgs e)
        {
            try
            {
                DataTable                 data = new DataTable();
                CPT_ResourceDemand        resourceDemandDetails = new CPT_ResourceDemand();
                List <CPT_ResourceMaster> lstdetils             = new List <CPT_ResourceMaster>();
                lstdetils = (List <CPT_ResourceMaster>)Session["UserDetails"];

                resourceDemandDetails.RequestID          = ClsCommon.GetRandomNumber(111111, 999999).ToString();
                resourceDemandDetails.AccountID          = Convert.ToInt32(AccountMasterID.SelectedValue);
                resourceDemandDetails.CityID             = Convert.ToInt32(CityID.SelectedValue);
                resourceDemandDetails.OpportunityID      = Convert.ToInt32(OpportunityID.SelectedValue);
                resourceDemandDetails.SalesStageID       = Convert.ToInt32(SalesStageMasterID.SelectedValue);
                resourceDemandDetails.ProcessName        = processName.Text.Trim();
                resourceDemandDetails.DateOfCreation     = DateTime.Now;
                resourceDemandDetails.DateOfModification = DateTime.Now;
                resourceDemandDetails.ResourceRequestBy  = lstdetils[0].EmployeeMasterID;
                resourceDemandDetails.StatusMasterID     = Convert.ToInt32(StatusMasterID.SelectedValue);
                resourceDemandDetails.PriorityID         = Convert.ToInt32(PriorityID.SelectedValue);

                ResourceDemandBL insertResourceDemand = new ResourceDemandBL();
                insertResourceDemand.Insert(resourceDemandDetails);

                if (ViewState["CurrentTable"] != null)
                {
                    DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
                    DataRow   drCurrentRow   = null;

                    if (dtCurrentTable.Rows.Count > 0)
                    {
                        drCurrentRow = dtCurrentTable.NewRow();
                        drCurrentRow["RowNumber"] = dtCurrentTable.Rows.Count + 1;

                        //add new row to DataTable
                        dtCurrentTable.Rows.Add(drCurrentRow);
                        //Store the current data to ViewState for future reference
                        ViewState["CurrentTable"] = dtCurrentTable;

                        for (int i = 0; i < dtCurrentTable.Rows.Count - 1; i++)
                        {
                            //extract the DropDownList Selected Items
                            DropDownList ddl = (DropDownList)GridviewResourceDetail.Rows[i].Cells[1].FindControl("ResourceTypeID");
                            //TextBox box1 = (TextBox)GridviewResourceDetail.Rows[i].Cells[1].FindControl("TextBox1");
                            TextBox box2 = (TextBox)GridviewResourceDetail.Rows[i].Cells[2].FindControl("NoOfResources");

                            dtCurrentTable.Rows[i]["ResourceTypeID"] = ddl.SelectedValue;
                            dtCurrentTable.Rows[i]["NoOfResources"]  = box2.Text.Trim();
                            ListBox ddl1 = (ListBox)GridviewResourceDetail.Rows[i].Cells[3].FindControl("SkillID");

                            // Update the DataRow with the DDL Selected Items
                            string message = "";
                            foreach (var z in ddl1.GetSelectedIndices())
                            {
                                message += ddl1.Items[z].Value + ",";
                            }
                            message = message.Remove(message.Length - 1).Trim();
                            dtCurrentTable.Rows[i]["SkillID"] = message;
                            Skill = message.Split(',');
                            id.Add(Skill);

                            //dtCurrentTable.Rows[i]["SkillID"] = id;

                            TextBox box3 = (TextBox)GridviewResourceDetail.Rows[i].Cells[2].FindControl("StartDate");
                            TextBox box4 = (TextBox)GridviewResourceDetail.Rows[i].Cells[2].FindControl("EndDate");
                            dtCurrentTable.Rows[i]["StartDate"] = box3.Text.Trim();
                            dtCurrentTable.Rows[i]["EndDate"]   = box4.Text.Trim();
                        }

                        //Rebind the Grid with the current data to reflect changes
                        GridviewResourceDetail.DataSource = dtCurrentTable;
                        GridviewResourceDetail.DataBind();
                    }
                    data = dtCurrentTable;
                }

                CPT_ResourceDetails demandDetails       = new CPT_ResourceDetails();
                ResourceDetailsBL   insertDemandDetails = new ResourceDetailsBL();

                for (int i = 0; i < data.Rows.Count - 1; i++)
                {
                    demandDetails.RequestID      = resourceDemandDetails.RequestID;
                    demandDetails.ResourceTypeID = Convert.ToInt32(data.Rows[i]["ResourceTypeID"]);
                    demandDetails.NoOfResources  = Convert.ToInt32(data.Rows[i]["NoOfResources"]);
                    demandDetails.SkillID        = data.Rows[i]["SkillID"].ToString().Trim();
                    demandDetails.StartDate      = Convert.ToDateTime(data.Rows[i]["StartDate"]);
                    demandDetails.EndDate        = Convert.ToDateTime(data.Rows[i]["EndDate"]);

                    insertDemandDetails.Insert(demandDetails);
                }

                Response.Redirect("ResourceDemand.aspx");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        protected void Add_Resource_Demand(object sender, EventArgs e)
        {
            try
            {
                DataTable                 data = new DataTable();
                CPT_ResourceDemand        resourceDemandDetails = new CPT_ResourceDemand();
                List <CPT_ResourceMaster> lstdetils             = new List <CPT_ResourceMaster>();
                lstdetils = (List <CPT_ResourceMaster>)Session["UserDetails"];

                resourceDemandDetails.RequestID = ClsCommon.GetRandomNumber(111111, 999999).ToString();
                resourceDemandDetails.AccountID = Convert.ToInt32(AccountMasterID.SelectedValue);
                int CityID = ResourceDemandBL.getCityID(Convert.ToInt32(AccountMasterID.SelectedValue));
                resourceDemandDetails.CityID             = CityID;
                resourceDemandDetails.OpportunityID      = Convert.ToInt32(OpportunityID.SelectedValue);
                resourceDemandDetails.SalesStageID       = Convert.ToInt32(SalesStageMasterID.SelectedValue);
                resourceDemandDetails.ProcessName        = processName.Text.Trim();
                resourceDemandDetails.DateOfCreation     = DateTime.Now;
                resourceDemandDetails.DateOfModification = DateTime.Now;
                resourceDemandDetails.ResourceRequestBy  = lstdetils[0].EmployeeMasterID;
                resourceDemandDetails.StatusMasterID     = 19;
                resourceDemandDetails.PriorityID         = 27;
                AccountName = AccountMasterID.SelectedItem.Text.Trim();
                ResourceDemandBL insertResourceDemand = new ResourceDemandBL();
                //insertResourceDemand.Insert(resourceDemandDetails);

                if (ViewState["CurrentTable"] != null)
                {
                    DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
                    DataRow   drCurrentRow   = null;

                    if (dtCurrentTable.Rows.Count > 0)
                    {
                        drCurrentRow = dtCurrentTable.NewRow();
                        drCurrentRow["RowNumber"] = dtCurrentTable.Rows.Count + 1;

                        //add new row to DataTable
                        dtCurrentTable.Rows.Add(drCurrentRow);
                        //Store the current data to ViewState for future reference
                        ViewState["CurrentTable"] = dtCurrentTable;

                        for (int i = 0; i < dtCurrentTable.Rows.Count - 1; i++)
                        {
                            //extract the DropDownList Selected Items
                            DropDownList ddl  = (DropDownList)GridviewResourceDetail.Rows[i].Cells[1].FindControl("ResourceTypeID");
                            DropDownList ddl1 = (DropDownList)GridviewResourceDetail.Rows[i].Cells[3].FindControl("ddlPrimary");
                            DropDownList ddl2 = (DropDownList)GridviewResourceDetail.Rows[i].Cells[4].FindControl("ddlSecondry");
                            DropDownList ddl3 = (DropDownList)GridviewResourceDetail.Rows[i].Cells[5].FindControl("ddlTernary");
                            //TextBox box1 = (TextBox)GridviewResourceDetail.Rows[i].Cells[1].FindControl("TextBox1");
                            TextBox box2 = (TextBox)GridviewResourceDetail.Rows[i].Cells[2].FindControl("NoOfResources");
                            TextBox box3 = (TextBox)GridviewResourceDetail.Rows[i].Cells[6].FindControl("StartDate");
                            TextBox box4 = (TextBox)GridviewResourceDetail.Rows[i].Cells[7].FindControl("EndDate");

                            dtCurrentTable.Rows[i]["ResourceTypeID"] = ddl.SelectedValue;
                            dtCurrentTable.Rows[i]["NoOfResources"]  = box2.Text.Trim();
                            dtCurrentTable.Rows[i]["PrimarySkill"]   = ddl1.SelectedValue;
                            dtCurrentTable.Rows[i]["SecondrySkill"]  = ddl2.SelectedValue;
                            dtCurrentTable.Rows[i]["TernarySkill"]   = ddl3.SelectedValue;
                            dtCurrentTable.Rows[i]["StartDate"]      = box3.Text.Trim();
                            dtCurrentTable.Rows[i]["EndDate"]        = box4.Text.Trim();
                            lstRoles.Add(ddl.SelectedItem.Text);
                            lstSkills.Add(ddl1.SelectedItem.Text + "," + ddl2.SelectedItem.Text + "," + ddl3.SelectedItem.Text);
                            lstStartDate.Add(box3.Text.Trim());
                            lstEnddate.Add(box4.Text.Trim());
                        }

                        //Rebind the Grid with the current data to reflect changes
                        GridviewResourceDetail.DataSource = dtCurrentTable;
                        GridviewResourceDetail.DataBind();
                    }
                    data = dtCurrentTable;
                }


                ResourceDetailsBL          insertDemandDetails = new ResourceDetailsBL();
                List <CPT_ResourceDetails> lstdetails          = new List <CPT_ResourceDetails>();

                for (int i = 0; i < data.Rows.Count - 1; i++)
                {
                    CPT_ResourceDetails details = new CPT_ResourceDetails();

                    details.RequestID      = resourceDemandDetails.RequestID;
                    details.ResourceTypeID = Convert.ToInt32(data.Rows[i]["ResourceTypeID"]);
                    details.NoOfResources  = (float)Convert.ToDouble(data.Rows[i]["NoOfResources"]);
                    details.SkillID        = data.Rows[i]["PrimarySkill"].ToString().Trim() + "," + data.Rows[i]["SecondrySkill"].ToString().Trim() + "," + data.Rows[i]["TernarySkill"].ToString().Trim();
                    details.StartDate      = Convert.ToDateTime(data.Rows[i]["StartDate"]);
                    details.EndDate        = Convert.ToDateTime(data.Rows[i]["EndDate"]);

                    lstdetails.Add(details);
                    resourceDemandDetails.CPT_ResourceDetails = lstdetails;

                    //insertDemandDetails.Insert(demandDetails);
                }
                insertResourceDemand.Insert(resourceDemandDetails);
                EmailNew(lstSkills, lstRoles, processName.Text.Trim(), lstStartDate, lstEnddate, AccountName);

                // Email();

                Response.Redirect("ResourceDemand.aspx");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }