Пример #1
0
        protected void gvSample_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                try
                {
                    LinkButton btnDelete = (LinkButton)e.Row.FindControl("btnDelete");
                    LinkButton btnEdit   = (LinkButton)e.Row.FindControl("btnEdit");
                    Literal    litRefNo  = (Literal)e.Row.FindControl("litRefNo");

                    if (litRefNo != null)
                    {
                        //int amend_count = Convert.ToInt16(gvSample.DataKeys[e.Row.RowIndex][6]);
                        //int retest_count = Convert.ToInt16(gvSample.DataKeys[e.Row.RowIndex][7]);

                        //String am = (amend_count == 0) ? String.Empty : String.Format("AM{0}", amend_count);
                        //String r = (retest_count == 0) ? String.Empty : String.Format("R{0}", retest_count);

                        //litRefNo.Text = String.Format("{0}{1}", litRefNo.Text, String.Format("{0}", String.IsNullOrEmpty(am + "" + r) ? String.Empty : "(" + am + "" + r + ")"));
                        #region "Check Amend/Retest"
                        int    amCount       = Convert.ToInt16(gvSample.DataKeys[e.Row.RowIndex][6]);
                        int    reCount       = Convert.ToInt16(gvSample.DataKeys[e.Row.RowIndex][7]);
                        String amendOrRetest = gvSample.DataKeys[e.Row.RowIndex][8] == null ? String.Empty : gvSample.DataKeys[e.Row.RowIndex][8].ToString();

                        switch (amendOrRetest)
                        {
                        case "AM":
                            litRefNo.Text = String.Format("{0}({1}{2})", litRefNo.Text, amendOrRetest, amCount);
                            break;

                        case "R":
                            litRefNo.Text = String.Format("{0}({1}{2})", litRefNo.Text, amendOrRetest, reCount);
                            break;
                        }
                        #endregion
                    }

                    Literal _litStatus_completion_scheduled = (Literal)e.Row.FindControl("litStatus_completion_scheduled");
                    if (btnDelete != null)
                    {
                        m_completion_scheduled m_completion_scheduled = new m_completion_scheduled();
                        m_completion_scheduled = m_completion_scheduled.SelectByID(Convert.ToInt32(_litStatus_completion_scheduled.Text));
                        if (m_completion_scheduled != null)
                        {
                            _litStatus_completion_scheduled.Text = m_completion_scheduled.name;
                        }
                        //btnDelete.Visible = (this.CommandName == CommandNameEnum.Add);
                        btnEdit.Visible = !(this.CommandName == CommandNameEnum.View);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine();
                }
            }
        }
Пример #2
0
        protected void gvSample_RowEditing(object sender, GridViewEditEventArgs e)
        {
            gvSample.EditIndex  = e.NewEditIndex;
            gvSample.DataSource = listSampleShow;
            gvSample.DataBind();

            String _no_of_report = gvSample.DataKeys[e.NewEditIndex].Values[3].ToString();
            String _uncertainty  = gvSample.DataKeys[e.NewEditIndex].Values[4].ToString();

            String       _status_completion_scheduled = gvSample.DataKeys[e.NewEditIndex].Values[5].ToString();
            DropDownList _ddlNoOfReport          = (DropDownList)gvSample.Rows[e.NewEditIndex].FindControl("ddlNoOfReport");
            DropDownList _ddlUncertaint          = (DropDownList)gvSample.Rows[e.NewEditIndex].FindControl("ddlUncertaint");
            DropDownList _ddlCompletionScheduled = (DropDownList)gvSample.Rows[e.NewEditIndex].FindControl("ddlCompletionScheduled");

            //int amend_count = Convert.ToInt16(gvSample.DataKeys[e.NewEditIndex].Values[6] == null ? "0" : gvSample.DataKeys[e.NewEditIndex].Values[6].ToString());
            //int retest_count = Convert.ToInt16(gvSample.DataKeys[e.NewEditIndex].Values[7] == null ? "0" : gvSample.DataKeys[e.NewEditIndex].Values[7].ToString());
            //String am = (amend_count == 0) ? String.Empty : String.Format("AM{0}", amend_count);
            //String r = (retest_count == 0) ? String.Empty : String.Format("R{0}", retest_count);

            TextBox txtRefNo = (TextBox)gvSample.Rows[e.NewEditIndex].FindControl("txtRefNo");

            //txtRefNo.Text = String.Format("{0}{1}", txtRefNo.Text, String.Format("{0}", String.IsNullOrEmpty(am + "" + r) ? String.Empty : "(" + am + "" + r + ")"));


            #region "Check Amend/Retest"
            //int amCount = Convert.ToInt16(gvSample.DataKeys[e.NewEditIndex][6]);
            //int reCount = Convert.ToInt16(gvSample.DataKeys[e.NewEditIndex][7]);
            String amendOrRetest = gvSample.DataKeys[e.NewEditIndex][8] == null ? String.Empty : gvSample.DataKeys[e.NewEditIndex][8].ToString();

            //switch (amendOrRetest)
            //{
            //    case "AM":
            //        txtRefNo.Text = String.Format("{0}({1}{2})", txtRefNo.Text.Split('(')[0], amendOrRetest, amCount);
            //        break;
            //    case "R":
            //        txtRefNo.Text = String.Format("{0}({1}{2})", txtRefNo.Text.Split('(')[0], amendOrRetest, reCount);
            //        break;
            //}
            #endregion



            txtRefNo.Enabled = String.IsNullOrEmpty(amendOrRetest);



            _ddlNoOfReport.Items.Clear();
            for (int i = 1; i <= 5; i++)
            {
                ListItem lt = new ListItem(i + "", i.ToString());
                _ddlNoOfReport.Items.Add(lt);
            }
            _ddlNoOfReport.SelectedValue = _no_of_report;

            _ddlUncertaint.Items.Clear();
            _ddlUncertaint.Items.Add(new ListItem("Y", "Y"));
            _ddlUncertaint.Items.Add(new ListItem("N", "N"));
            _ddlUncertaint.SelectedValue = _uncertainty;


            m_completion_scheduled m_completion_scheduled = new m_completion_scheduled();
            _ddlCompletionScheduled.DataSource = m_completion_scheduled.SelectAll();
            _ddlCompletionScheduled.DataBind();
        }
Пример #3
0
        private void initialPage()
        {
            this.listSample = new List <job_sample>();

            m_customer customer = new m_customer();

            ddlCustomer_id.Items.Clear();
            ddlCustomer_id.DataSource = customer.SelectAll();
            ddlCustomer_id.DataBind();
            ddlCustomer_id.Items.Insert(0, new ListItem(Constants.PLEASE_SELECT, ""));

            ddlContract_person_id.Items.Clear();
            ddlContract_person_id.Items.Insert(0, new ListItem(Constants.PLEASE_SELECT, ""));

            m_specification specification = new m_specification();

            ddlSecification_id.Items.Clear();
            ddlSecification_id.DataSource = specification.SelectAll();
            ddlSecification_id.DataBind();
            ddlSecification_id.Items.Insert(0, new ListItem(Constants.PLEASE_SELECT, ""));



            ddlJobNumber.Items.Clear();
            ddlJobNumber.DataSource = new job_running().SelectAll();
            ddlJobNumber.DataBind();
            ddlJobNumber.Items.Insert(0, new ListItem(Constants.PLEASE_SELECT, ""));


            m_completion_scheduled m_completion_scheduled = new m_completion_scheduled();

            ddlCompletionScheduled.DataSource = m_completion_scheduled.SelectAll();
            ddlCompletionScheduled.DataBind();

            ddlAddress.Items.Clear();
            ddlAddress.Items.Insert(0, new ListItem(Constants.PLEASE_SELECT, ""));

            ddlStatus.Items.Clear();
            ddlStatus.DataSource = new m_status().SelectByMainStatus();
            ddlStatus.DataBind();
            ddlStatus.Items.Insert(0, new ListItem(Constants.PLEASE_SELECT, ""));


            switch (CommandName)
            {
            case CommandNameEnum.Add:
                txtDateOfRequest.Text   = DateTime.Now.ToString("dd/MM/yyyy");
                txtDate_of_receive.Text = DateTime.Now.ToString("dd/MM/yyyy");

                ddlCustomer_id.Enabled        = true;
                ddlContract_person_id.Enabled = true;
                ddlSecification_id.Enabled    = true;
                txtDateOfRequest.Enabled      = true;
                txtCustomer_ref_no.Enabled    = true;
                txtCompany_name_to_state_in_report.Attributes.Remove("readonly");
                //txtCompany_name_to_state_in_report.Attributes["readonly"] = "readonly";
                txtJob_number.Enabled      = true;
                txtDate_of_receive.Enabled = true;
                //txtS_pore_ref_no.Enabled = true;
                txtSpecRefRevNo.Enabled            = true;
                txtCustomer_ref_no.Enabled         = true;
                rdSample_enoughNo.Enabled          = true;
                rdPersonel_and_workloadYes.Enabled = true;
                rdPersonel_and_workloadYes.Enabled = true;
                rdTest_toolYes.Enabled             = true;
                rdTest_methodYes.Enabled           = true;
                //rdCompletion_scheduledNormal_Normal.Enabled = true;
                //rdCompletion_scheduledNormal_Urgent.Enabled = true;
                //rdCompletion_scheduledNormal_Express.Enabled = true;
                rdSample_dipositionYes.Enabled = true;

                //txtSpecification_other.Enabled = true;
                //lbOther.Visible = false;


                btnAddSampleInfo.Enabled = true;
                btnSave.Enabled          = true;
                btnCancel.Enabled        = true;


                break;

            case CommandNameEnum.Edit:
                fillinScreen();


                btnAddSampleInfo.Enabled = true;
                btnSave.Enabled          = true;
                btnCancel.Enabled        = true;


                break;

            case CommandNameEnum.View:
                fillinScreen();

                ddlCustomer_id.Attributes["readonly"]        = "readonly";
                ddlContract_person_id.Attributes["readonly"] = "readonly";
                ddlSecification_id.Attributes["readonly"]    = "readonly";
                txtDateOfRequest.Attributes["readonly"]      = "readonly";
                txtCustomer_ref_no.Attributes["readonly"]    = "readonly";
                txtCompany_name_to_state_in_report.Attributes["readonly"] = "readonly";
                txtJob_number.Attributes["readonly"]      = "readonly";
                txtDate_of_receive.Attributes["readonly"] = "readonly";
                //txtS_pore_ref_no.Attributes["readonly"] = "readonly";
                txtSpecRefRevNo.Attributes["readonly"]            = "readonly";
                txtCustomer_ref_no.Attributes["readonly"]         = "readonly";
                rdSample_enoughNo.Attributes["readonly"]          = "readonly";
                rdPersonel_and_workloadYes.Attributes["readonly"] = "readonly";
                rdPersonel_and_workloadYes.Attributes["readonly"] = "readonly";
                rdTest_toolYes.Attributes["readonly"]             = "readonly";
                rdTest_methodYes.Attributes["readonly"]           = "readonly";
                //rdCompletion_scheduledNormal_Normal.Attributes["readonly"] = "readonly";
                //rdCompletion_scheduledNormal_Urgent.Attributes["readonly"] = "readonly";
                //rdCompletion_scheduledNormal_Express.Attributes["readonly"] = "readonly";
                rdSample_dipositionYes.Attributes["readonly"] = "readonly";

                //txtSpecification_other.Enabled = false;
                //lbOther.Visible = false;
                btnAddSampleInfo.Enabled = false;
                btnSave.Enabled          = false;
                btnCancel.Enabled        = true;

                break;
            }

            //txtSpecification_other.Visible = false;
        }
Пример #4
0
        protected void btnAddSampleInfo_Click(object sender, EventArgs e)
        {
            foreach (ListItem item in lstTypeOfTest.Items)
            {
                if (item.Selected)
                {
                    m_type_of_test tmp = new m_type_of_test().SelectByID(int.Parse(item.Value));
                    if (tmp != null)
                    {
                        job_sample jobSample = new job_sample();
                        jobSample.ID          = CustomUtils.GetRandomNumberID();
                        jobSample.template_id = -1;


                        jobSample.job_id           = Convert.ToInt32(hJobID.Value);
                        jobSample.type_of_test_id  = tmp.ID;
                        jobSample.specification_id = String.IsNullOrEmpty(ddlSecification_id.SelectedValue) ? 0 : int.Parse(ddlSecification_id.SelectedValue);
                        jobSample.job_number       = ddlJobNumber.SelectedItem.Text + "-" + txtJob_number.Text + "-" + tmp.prefix;
                        jobSample.description      = txtDescriptoin.Text;
                        jobSample.model            = txtModel.Text;
                        jobSample.surface_area     = txtSurfaceArea.Text;
                        jobSample.remarks          = txtRemark.Text;
                        jobSample.no_of_report     = 1;// Convert.ToInt16(ddlNoOfReport.SelectedValue);
                        jobSample.uncertainty      = (rdUncertaintyYes.Checked) ? "Y" : "N";
                        jobSample.RowState         = CommandNameEnum.Add;
                        jobSample.job_status       = Convert.ToInt32(StatusEnum.LOGIN_CONVERT_TEMPLATE);


                        jobSample.job_role = userLogin.role_id;
                        jobSample.status_completion_scheduled = Convert.ToInt32(ddlCompletionScheduled.SelectedValue);
                        //jobSample.due_date = Convert.ToDateTime(objJobInfo.date_of_receive.Value);
                        jobSample.update_date  = Convert.ToDateTime(objJobInfo.date_of_receive.Value);
                        jobSample.update_by    = userLogin.id;
                        jobSample.is_hold      = "0";//0=Unhold
                        jobSample.part_no      = txtPartNo.Text;
                        jobSample.part_name    = txtPartName.Text;
                        jobSample.lot_no       = txtLotNo.Text;
                        jobSample.other_ref_no = txtOtherRefNo.Text;
                        #region "Special Flow"

                        /*
                         * ELP:       Login(convert template , select spec) > Chemist testing > Sr. chemist checking > Admin(Word) > Lab Manager > Admin (Upload file PDF)
                         * ELS:         Login(convert template(Ad hoc template)) >Chemist testing(Upload file) > Sr. chemist checking
                         * ELN:         Login(convert template(Ad hoc template)) > Chemist testing(Upload file) > Sr. chemist checking > Admin(Word) > Lab Manager  Admin (Upload file PDF)
                         * FA:         Login > Chemist testing(Upload file) > Admin(Word) > Lab Manager > Admin (Upload file PDF)
                         * GRP:         Login > Admin(Upload file PDF)
                         * ELWA :       Login > Chemist testing(Upload file) > Sr. chemist checking > Admin(Word) > Lab Manager > Admin (Upload file PDF)
                         * */

                        if (!String.IsNullOrEmpty(ddlJobNumber.SelectedValue))
                        {
                            switch (ddlJobNumber.SelectedItem.Text.ToUpper())
                            {
                            case "ELS":
                                jobSample.template_id = 1;
                                jobSample.job_status  = Convert.ToInt32(StatusEnum.CHEMIST_TESTING);
                                break;

                            case "ELN":

                                if (tmp.ref_template_id != null)
                                {
                                    jobSample.template_id = tmp.ref_template_id.Value;
                                }
                                else
                                {
                                    jobSample.template_id = 2;
                                }


                                jobSample.job_status = Convert.ToInt32(StatusEnum.CHEMIST_TESTING);

                                break;

                            case "FA":
                                jobSample.template_id = 3;
                                jobSample.job_status  = Convert.ToInt32(StatusEnum.CHEMIST_TESTING);
                                break;

                            case "GRP":
                                jobSample.template_id = 4;
                                jobSample.job_status  = Convert.ToInt32(StatusEnum.ADMIN_CONVERT_PDF);
                                break;

                            case "ELWA":
                                jobSample.template_id = 5;
                                jobSample.job_status  = Convert.ToInt32(StatusEnum.CHEMIST_TESTING);
                                break;

                            default:    //ELP
                                break;
                            }
                        }
                        #endregion

                        m_completion_scheduled cs = new m_completion_scheduled().SelectByID(Convert.ToInt32(jobSample.status_completion_scheduled));
                        if (cs != null)
                        {
                            if (objJobInfo != null)
                            {
                                if (Constants.OTHER_REF_NOS.Contains(jobSample.other_ref_no))
                                {
                                    jobSample.due_date_lab      = new DateTime(1, 1, 1);
                                    jobSample.due_date_customer = Convert.ToDateTime(objJobInfo.date_of_receive.Value).AddDays(Convert.ToInt32(cs.customer_due_date));
                                }
                                else
                                {
                                    jobSample.due_date          = Convert.ToDateTime(objJobInfo.date_of_receive.Value).AddDays(Convert.ToInt32(cs.value));
                                    jobSample.due_date_customer = Convert.ToDateTime(objJobInfo.date_of_receive.Value).AddDays(Convert.ToInt32(cs.customer_due_date));
                                    jobSample.due_date_lab      = Convert.ToDateTime(objJobInfo.date_of_receive.Value).AddDays(Convert.ToInt32(cs.lab_due_date));
                                }
                            }
                        }
                        else
                        {
                            //logger.Debug("m_completion_scheduled is Empty!");
                        }
                        jobSample.sample_prefix = ddlJobNumber.SelectedItem.Text;

                        listSample.Add(jobSample);
                    }
                    else
                    {
                        // not find type of test
                    }
                }
            }

            gvSample.DataSource = listSampleShow;
            gvSample.PageIndex  = 0;
            gvSample.DataBind();
            //Clear old value

            //txtDescriptoin.Text = string.Empty;
            //txtModel.Text = string.Empty;
            //txtSurfaceArea.Text = string.Empty;
            //txtRemark.Text = string.Empty;
            //rdUncertaintyNo.Checked = true;
            //ddlSecification_id.SelectedIndex = -1;
            //ddlCompletionScheduled.SelectedIndex = -1;
            lstTypeOfTest.ClearSelection();
        }
        protected void gvJob_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            CommandNameEnum        cmd = (CommandNameEnum)Enum.Parse(typeof(CommandNameEnum), e.CommandName, true);
            m_completion_scheduled cs  = new m_completion_scheduled().SelectByID(Convert.ToInt32(CompletionScheduledEnum.NORMAL));

            this.CommandName = cmd;
            this.JobID       = (cmd == CommandNameEnum.Page) ? 0 : int.Parse(e.CommandArgument.ToString().Split(Constants.CHAR_COMMA)[0]);
            this.SampleID    = (cmd == CommandNameEnum.Page) ? 0 : int.Parse(e.CommandArgument.ToString().Split(Constants.CHAR_COMMA)[1]);

            switch (cmd)
            {
            case CommandNameEnum.Edit:
            //Server.Transfer(Constants.LINK_EDIT_SAMPLE);
            //break;
            case CommandNameEnum.View:
                Server.Transfer(Constants.LINK_JOB_REQUEST);
                break;

            case CommandNameEnum.ConvertTemplate:
                Server.Transfer(Constants.LINK_JOB_CONVERT_TEMPLATE);
                break;

            case CommandNameEnum.Workflow:
                Server.Transfer(Constants.LINK_JOB_WORK_FLOW);
                break;

            case CommandNameEnum.ChangeStatus:
                Server.Transfer(Constants.LINK_JOB_CHANGE_STATUS);
                break;

            case CommandNameEnum.ChangeDueDate:
                Server.Transfer(Constants.LINK_JOB_CHANGE_DUEDATE);
                break;

            case CommandNameEnum.ChangeSrCompleteDate:
                Server.Transfer(Constants.LINK_JOB_SR_COMPLETE_DATE);
                break;

            case CommandNameEnum.ChangePo:
                Server.Transfer(Constants.LINK_JOB_CHANGE_PO);
                break;

            case CommandNameEnum.ChangeInvoice:
                Server.Transfer(Constants.LINK_JOB_CHANGE_INVOICE);
                break;

            case CommandNameEnum.Print:
                if (userLogin.role_id == Convert.ToInt32(RoleEnum.ADMIN))
                {
                    Server.Transfer(Constants.LINK_ADMIN_PRINT);
                }
                else
                {
                    Server.Transfer(Constants.LINK_JOB_PRINT_LABEL);
                }
                break;

            case CommandNameEnum.ChangeReportDate:
                Server.Transfer(Constants.LINK_REPORT_DATE);
                break;

            case CommandNameEnum.ChangeOtherRefNo:
                Server.Transfer(Constants.LINK_CHANGE_OTHER_REF_NO);
                break;

            case CommandNameEnum.ChangeSingaporeRefNo:
                Server.Transfer(Constants.LINK_CHANGE_SINGAPORE_REF_NO);
                break;

            case CommandNameEnum.Amend:
            case CommandNameEnum.Retest:
                Server.Transfer(Constants.LINK_RETEST);
                break;

            case CommandNameEnum.Hold:
                if (cs != null)
                {
                    job_sample jobSample = new job_sample().SelectByID(this.SampleID);
                    jobSample.update_date = DateTime.Now;
                    jobSample.is_hold     = "1";
                    jobSample.Update();
                    //Commit
                    GeneralManager.Commit();
                    bindingData();
                }
                break;

            case CommandNameEnum.UnHold:
                if (cs != null)
                {
                    job_sample jobSample = new job_sample().SelectByID(this.SampleID);
                    jobSample.update_date       = DateTime.Now;
                    jobSample.due_date          = (jobSample.update_date == null) ? DateTime.Now.AddDays(cs.value.Value) : jobSample.update_date.Value.AddDays(cs.value.Value);
                    jobSample.due_date_customer = (jobSample.update_date == null) ? DateTime.Now.AddDays(cs.lab_due_date.Value) : jobSample.update_date.Value.AddDays(cs.lab_due_date.Value);
                    jobSample.due_date_lab      = (jobSample.update_date == null) ? DateTime.Now.AddDays(cs.customer_due_date.Value) : jobSample.update_date.Value.AddDays(cs.customer_due_date.Value);
                    jobSample.is_hold           = "0";
                    jobSample.job_status        = Convert.ToInt16(StatusEnum.CHEMIST_TESTING);
                    jobSample.Update();
                    //Commit
                    GeneralManager.Commit();
                    bindingData();
                }
                break;

            case CommandNameEnum.ViewFile:
                Server.Transfer(Constants.LINK_VIEW_FILE);
                break;
            }
        }