protected void gridViewJobFlow_Command(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Select")
     {
         GetMyAccessRights();
         JobFlow jobflow = new JobFlow();
         modalLabelError.Text = "";
         modalLabelError.Visible = false;
         int index = Convert.ToInt32(e.CommandArgument);
         int jobflowId = Convert.ToInt32(((Label)gridViewJobFlow.Rows[index].FindControl("labelJobFlowId")).Text);
         modalLabelJobFlowId.Text = jobflowId.ToString();
         jobflow = jobflow.GetJobFlow(jobflowId);
         modalTxtBoxDescription.Text = jobflow.Description;
         modalTxtBoxAcronym.Text = jobflow.Acronym;
         modalTxtBoxPosition.Text = jobflow.Position.ToString();
         InitializeModalJobType();
         InitializeModalGridView();
         InitializeModalDepartment();
         modalBtnSubmit.Visible = Convert.ToBoolean(myAccessRights.CanUpdate);
         programmaticModalPopup.Show();
     }
 }
        private void GenerateFlowRows(ref DataTable table)
        {
            JobFlow jobflow = new JobFlow();
            JobTypeFlow jobtypeFlow = new JobTypeFlow();
            JobTracker jobtracker = new JobTracker();
            //var jobflows = jobflow.GetJobOverviewJobFlow();
            //var distinctProjectList = jobtracker.GetDistinctProjectList(Convert.ToDateTime(txtBoxStartDate.Text + " 00:00:00"), Convert.ToDateTime(txtBoxEndDate.Text + " 23:59:59"), txtBoxJobId.Text.Trim());

            foreach (JobTracker p in distincProjectList)
            {
                DataRow row = table.NewRow();
                row["HW No"] = p.HWNo == null ? "" : p.HWNo.Trim();
                row["SW No"] = p.SWNo == null ? "" : p.SWNo.Trim();
                row["Customer"] = p.Customer == null ? "" : p.Customer.Trim();
                row["Description"] = p.Description == null ? "" : p.Description.Trim();
                for (int x = 0; x < jobflowList.Count; x++)
                {
                    //var jobtypes = jobtypeFlow.GetJobTypeFlowListByJobFlow(jobflowList[x].Id);
                    for (int i = 0; i < jobtypeflowlist[x].Count; i++)
                    {
                        JobTracker j = new JobTracker();
                        string deptacro = "";
                        if (jobtypeflowlist[x][i].DepartmentId != null)
                            deptacro = jobtypeflowlist[x][i].departmentAcronym;

                        if (jobtypeflowlist[x][i].DepartmentId != null)
                        {
                            j = jobtracker.GetJobTrackerJobOverview(jobtypeflowlist[x][i].JobTypeId, p.SWNo, p.HWNo, Convert.ToDateTime(txtBoxStartDate.Text + " 00:00:00"), Convert.ToDateTime(txtBoxEndDate.Text + " 23:59:59"), Convert.ToInt32(jobtypeflowlist[x][i].DepartmentId));
                        }
                        else
                        {
                            j = jobtracker.GetJobTrackerJobOverview(jobtypeflowlist[x][i].JobTypeId, p.SWNo, p.HWNo, Convert.ToDateTime(txtBoxStartDate.Text + " 00:00:00"), Convert.ToDateTime(txtBoxEndDate.Text + " 23:59:59"));
                        }
                        if (j == null)
                        {
                            row[jobtypeflowlist[x][i].jobtypeAcronym + deptacro + "" + jobflowList[x].Id] = "";
                        }
                        else
                        {
                            row[jobtypeflowlist[x][i].jobtypeAcronym + deptacro + "" + jobflowList[x].Id] = j.Id + "|" + j.JobStatus + " " + Convert.ToDateTime(j.EndTime).ToString("dd-MMM-yyyy");
                        }
                    }
                }
                table.Rows.Add(row);
            }
        }
        private DataTable GenerateFlowColumns()
        {
            DataTable table = new DataTable();

            JobFlow jobflow = new JobFlow();
            JobTypeFlow jobtypeflow = new JobTypeFlow();
            jobflowList = jobflow.GetJobOverviewJobFlow();
            DataColumn hwCol = new DataColumn("HW No", typeof(System.String));
            DataColumn swCol = new DataColumn("SW No", typeof(System.String));
            DataColumn cusCol = new DataColumn("Customer", typeof(System.String));
            DataColumn jdCol = new DataColumn("Description", typeof(System.String));
            table.Columns.Add(hwCol);
            table.Columns.Add(swCol);
            table.Columns.Add(cusCol);
            table.Columns.Add(jdCol);

            BoundField bfHw = new BoundField();
            bfHw.HeaderText = "HW No";
            bfHw.DataField = "HW No";

            BoundField bfSw = new BoundField();
            bfSw.HeaderText = "SW No";
            bfSw.DataField = "SW No";

            BoundField bfCus = new BoundField();
            bfCus.HeaderText = "Customer";
            bfCus.DataField = "Customer";

            BoundField bfDes = new BoundField();
            bfDes.HeaderText = "Description";
            bfDes.DataField = "Description";

            gridViewJobFlow.Columns.Add(bfHw);
            gridViewJobFlow.Columns.Add(bfSw);
            gridViewJobFlow.Columns.Add(bfCus);
            gridViewJobFlow.Columns.Add(bfDes);
            jobtypeflowlist = new List<List<JobTypeFlow>>();
            for (int x = 0; x < jobflowList.Count;x++ ) //Creates the columns
            {
                var jobtypes = jobtypeflow.GetJobTypeFlowListByJobFlow(jobflowList[x].Id);
                jobtypeflowlist.Add(jobtypes);
                for (int i = 0; i < jobtypes.Count; i++)
                {
                    string deptacro = "";
                    if (jobtypes[i].DepartmentId != null)
                        deptacro = jobtypes[i].departmentAcronym;
                    DataColumn col = new DataColumn(jobtypes[i].jobtypeAcronym + deptacro + "" + jobflowList[x].Id, typeof(System.String));
                    table.Columns.Add(col);

                    TemplateField tfield = new TemplateField();
                    string sdept = "";
                    if (jobtypes[i].DepartmentId != null)
                        sdept = jobtypes[i].departmentAcronym + "-";
                    tfield.HeaderText = sdept + jobtypes[i].jobtypeAcronym;
                    gridViewJobFlow.Columns.Add(tfield);
                }
            }

            return table;
        }
 protected void gridViewJobFlow_RowCreated(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.Header)
     {
         GridViewRow gvr = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);
         TableHeaderCell thc = new TableHeaderCell();
         thc.ColumnSpan = 4;
         thc.Text = "General Info";
         //thc.BackColor = System.Drawing.Color.Yellow;
         gvr.Cells.Add(thc);
         System.Drawing.Color backcolor = System.Drawing.ColorTranslator.FromHtml("#164BDB");
         System.Drawing.Color forecolor = System.Drawing.Color.White;
         JobFlow jobflow = new JobFlow();
         JobTypeFlow jobtypeflow = new JobTypeFlow();
         //var jobflows = jobflow.GetJobOverviewJobFlow();
         int rowIndex = 4;
         for (int i = 0; i < jobflowList.Count; i++)
         {
             if (i % 2 != 0)
             {
                 backcolor = System.Drawing.ColorTranslator.FromHtml("#0D72FF");
                 //forecolor = System.Drawing.ColorTranslator.FromHtml("#2e6e9e");
                 forecolor = System.Drawing.Color.White;
             }
             else
             {
                 backcolor = System.Drawing.ColorTranslator.FromHtml("#164BDB");
                 forecolor = System.Drawing.Color.White;
             }
             //var jobtypes = jobtypeflow.GetJobTypeFlowListByJobFlow(jobflowList[i].Id);
             if (jobtypeflowlist[i].Count > 0)
             {
                 thc = new TableHeaderCell();
                 thc.BackColor = backcolor;
                 thc.ForeColor = forecolor;
                 thc.ColumnSpan = jobtypeflowlist[i].Count;
                 thc.Text = jobflowList[i].Description;
                 gvr.Cells.Add(thc);
             }
             for (int x = 0; x < jobtypeflowlist[i].Count; x++)
             {
                 e.Row.Cells[rowIndex].BackColor = backcolor;
                 e.Row.Cells[rowIndex].ForeColor = forecolor;
                 rowIndex++;
             }
         }
         gridViewJobFlow.Controls[0].Controls.AddAt(0, gvr);
     }
 }
        protected void modalAcronym_Changed(object sender, EventArgs e)
        {
            string errorMsg = "Acronym already used.";
            if (modalTxtBoxAcronym.Text.Trim() != "")
            {
                JobFlow jobflow = new JobFlow();
                jobflow = jobflow.GetJobFlowByAcronym(modalTxtBoxAcronym.Text.Trim());

                if (jobflow != null)
                {
                    if (modalLabelJobFlowId.Text.Trim() == "")
                    {
                        modalLabelError.Text += errorMsg;
                        modalLabelError.Visible = true;
                    }
                    else
                    {
                        JobFlow j = jobflow.GetJobFlow(Convert.ToInt32(modalLabelJobFlowId.Text));
                        if (j.Acronym.Trim().Equals(modalTxtBoxAcronym.Text.Trim(), StringComparison.OrdinalIgnoreCase) == true)
                        {
                            modalLabelError.Text += errorMsg;
                            modalLabelError.Visible = true;
                        }
                        else
                        {
                            modalLabelError.Text = modalLabelError.Text.Replace(errorMsg, "").Trim();
                        }
                    }
                }
                else
                {
                    modalLabelError.Text = modalLabelError.Text.Replace(errorMsg, "").Trim();
                }
            }
            else
            {
                modalLabelError.Text = modalLabelError.Text.Replace(errorMsg, "").Trim();
            }
            if (modalLabelError.Text.Trim().Length == 0)
            {
                modalLabelError.Visible = false;
            }
            this.programmaticModalPopup.Show();
        }
        private void InitializeMainGrid()
        {
            GetMyAccessRights();

            JobFlow jobflow = new JobFlow();
            if (myAccessRights.CanAdd == true)
            {
                linkBtnAdd.Visible = true;
            }
            else
                linkBtnAdd.Visible = false;

            List<JobFlow> jobflowList = new List<JobFlow>();
            jobflowList = jobflow.GetJobFlowList();
            gridViewJobFlow.DataSource = jobflowList;
            gridViewJobFlow.DataBind();
        }
        protected void modalBtnSubmit_Command(object sender, CommandEventArgs e)
        {
            if (gridViewModal.Rows.Count == 0 ||(modalLabelJobFlowId.Text.Trim() != "" && IsCheckBoxEmpty()))
            {
                modalLabelError.Visible = true;
                modalLabelError.Text += " Please add atleast one department.";
                this.programmaticModalPopup.Show();
            }
            else if (modalLabelError.Visible == true)
                this.programmaticModalPopup.Show();
            else
            {
                JobFlow jobflow = new JobFlow();

                if (modalLabelJobFlowId.Text.Trim() != "")
                {
                    jobflow = jobflow.GetJobFlow(Convert.ToInt32(modalLabelJobFlowId.Text));
                }
                jobflow.Description = modalTxtBoxDescription.Text.Trim();
                jobflow.Acronym = modalTxtBoxAcronym.Text.Trim();
                jobflow.Position = modalTxtBoxPosition.Text.Trim() == "" ? 0 : Convert.ToInt32(modalTxtBoxPosition.Text);

                if (modalLabelJobFlowId.Text.Trim() == "")
                {
                    jobflow.Insert(jobflow);
                    jobflow = jobflow.GetJobFlowByDescription(jobflow.Description);
                }
                else
                {
                    jobflow.Update(jobflow);
                }

                for (int i = 0; i < gridViewModal.Rows.Count; i++)
                {
                    JobTypeFlow jobTypeFlow = new JobTypeFlow();
                    CheckBox cb = (CheckBox)gridViewModal.Rows[i].FindControl("modalChkJobType");
                    Label labelJobTypeId = (Label)gridViewModal.Rows[i].FindControl("modalLabelJobTypeId");
                    Label labelDeptId = (Label)gridViewModal.Rows[i].FindControl("modalLabelDepartmentId");
                    TextBox txtBoxPosition = (TextBox)gridViewModal.Rows[i].FindControl("modalInnerTxtBoxPostion");

                    int jobtypeid = Convert.ToInt32(labelJobTypeId.Text);
                    int? deptid = Convert.ToInt32(labelDeptId.Text.Trim() == "" ? "0" : labelDeptId.Text);
                    if(deptid == 0)
                        deptid = null;
                    jobTypeFlow = jobTypeFlow.GetJobTypeFlow(jobflow.Id,jobtypeid,deptid);
                    if (cb.Checked)
                    {
                        if (jobTypeFlow == null)
                        {
                            jobTypeFlow = new JobTypeFlow();
                            jobTypeFlow.JobFlowId = jobflow.Id;
                            jobTypeFlow.JobTypeId = jobtypeid;
                            jobTypeFlow.DepartmentId = deptid;
                            jobTypeFlow.Position = txtBoxPosition.Text.Trim() == "" ? 0 : Convert.ToInt32(txtBoxPosition.Text.Trim());
                            jobTypeFlow.Insert(jobTypeFlow);
                        }
                        else
                        {
                            jobTypeFlow.Position = txtBoxPosition.Text.Trim() == "" ? 0 : Convert.ToInt32(txtBoxPosition.Text.Trim());
                            jobTypeFlow.Update(jobTypeFlow);
                        }
                    }
                    else
                    {
                        if (jobTypeFlow != null)
                        {
                            jobTypeFlow.Delete(jobTypeFlow.Id);
                        }
                    }
                }
                if(IsCheckBoxEmpty())
                {
                    jobflow.Delete(jobflow.Id);
                }
                Session["JobFlows"] = null;
                InitializeMainGrid();
            }
        }
Exemplo n.º 8
0
 //Parsing done before updating or inserting jobflow in database
 private void ParseJobFlow(T_JobFlow t_jobflow, JobFlow jobflow)
 {
     t_jobflow.Description = jobflow.Description;
     t_jobflow.Position = jobflow.Position;
     t_jobflow.Acronym = jobflow.Acronym;
 }
Exemplo n.º 9
0
 //Update JobFlow in Database
 public void Update(JobFlow jobflow)
 {
     using (TimeTrackerEntities db = new TimeTrackerEntities())
     {
         try
         {
             T_JobFlow t_jobflow = db.T_JobFlow.FirstOrDefault(f => f.Id == jobflow.Id);
             ParseJobFlow(t_jobflow, jobflow);
             db.SaveChanges();
         }
         catch (Exception ex)
         {
             string msg = ex.Message;
         }
     }
 }
Exemplo n.º 10
0
        //Insert new JobFlow in Database
        public void Insert(JobFlow jobflow)
        {
            T_JobFlow t_jobflow = new T_JobFlow();
            ParseJobFlow(t_jobflow,jobflow);

            using (TimeTrackerEntities db = new TimeTrackerEntities())
            {
                try
                {
                    db.T_JobFlow.Add(t_jobflow);
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    string msg = ex.Message;
                }
            }
        }