//public bool IsDup { get; set; }



    public Calculation_T6(int intResultSectionID, int TransactionID)
    {
        this.ResultSectionID = intResultSectionID;
        this.TransactionID   = TransactionID;



        Model_ReportSectionItem rss = new Model_ReportSectionItem();

        this.ReportSectionItem = rss.GetListItemBySectionID(this.ResultSectionID);



        Model_ReportItemResult ret = new Model_ReportItemResult();

        this.ReportResultT4 = ret.GetItemReportByTransactionID(this.TransactionID, 4);
        this.ReportResultT2 = ret.GetItemReportByTransactionID(this.TransactionID, 2);

        Model_Jobfunction cj = new Model_Jobfunction();

        this.JobFunctionList = cj.GetAll();

        Model_JobFunctionListMain cjm = new Model_JobFunctionListMain();

        this.JobFunctionListMain = cjm.GetAllActive();

        Model_JobFunctionListMap cjmap = new Model_JobFunctionListMap();

        this.JobFunctionListMap = cjmap.GetAllList();

        Model_JFR1 r1 = new Model_JFR1();

        this.Rule1 = r1.GetAll();
        Model_JFR2 r2 = new Model_JFR2();

        this.Rule2 = r2.GetAll();
        Model_JFR3 r3 = new Model_JFR3();

        this.Rule3 = r3.GetAll();
        Model_JFR4 r4 = new Model_JFR4();

        this.Rule4 = r4.GetAll();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.Page.IsPostBack)
        {
            Model_Jobfunction j = new Model_Jobfunction();

            droupJob.DataSource     = j.GetAll();
            droupJob.DataTextField  = "Title";
            droupJob.DataValueField = "JFID";
            droupJob.DataBind();

            JobFunctionListdrop.DataSource     = j.GetAll();
            JobFunctionListdrop.DataTextField  = "Title";
            JobFunctionListdrop.DataValueField = "JFID";
            JobFunctionListdrop.DataBind();

            Model_JobFunctionListMain main = new Model_JobFunctionListMain();
            dropScoreMain.DataSource     = main.GetAllActive();
            dropScoreMain.DataTextField  = "Title";
            dropScoreMain.DataValueField = "JFMID";
            dropScoreMain.DataBind();


            if (!string.IsNullOrEmpty(Request.QueryString["g"]) && !string.IsNullOrEmpty(Request.QueryString["m"]))
            {
                add_section.Visible = true;
                int JFID  = int.Parse(Request.QueryString["g"]);
                int JFMID = int.Parse(Request.QueryString["m"]);
                Model_JobFunctionListMap cgroup = new Model_JobFunctionListMap();
                cgroup = cgroup.GetByID(JFID, JFMID);


                Score.Text = cgroup.Score.ToString();

                JobFunctionListdrop.SelectedValue = JFID.ToString();

                dropScoreMain.SelectedValue = cgroup.JFMID.ToString();

                headsection_pan.InnerHtml = "Edit";
            }
        }
    }
    protected void btnImport_Click(object sender, EventArgs e)
    {
        string strFileName = string.Empty;
        string strPath     = string.Empty;


        Base64BinarySrtingToFile save = new Base64BinarySrtingToFile
        {
            FilePrefix = "1"
        };

        save.SaveFileNew(HttpContext.Current.Request.Files["ctl00$MainContent$fileImport"]);



        if (save.IsSaved)
        {
            strFileName = save.FileName;
            strPath     = save.Path;

            DataTable data = null;

            data = new GsCsvReader(strPath, strFileName, 1, 26).ResultDataTable;

            if (data.Rows.Count > 0)
            {
                Model_Jobfunction cde = new Model_Jobfunction();
                //cde.DeleteAll();
                int count = 0;

                Model_JobFunctionListMain cm = new Model_JobFunctionListMain();


                Model_ReportSectionItem cc = new Model_ReportSectionItem();

                cc.Delete(6);
                foreach (DataRow row in data.Rows)
                {
                    if (count > 0)
                    {
                        Model_Jobfunction cSub = new Model_Jobfunction
                        {
                            JFID  = int.Parse(row[2].ToString()),
                            JGID  = int.Parse(row[0].ToString()),
                            Title = row[3].ToString()
                                    //Email = (row.Table.Columns.Contains("Email") ? (row["Email"] == DBNull.Value ? "" : (string)row["Email"]) : ""),
                                    //FirstName = (row.Table.Columns.Contains("FirstName") ? (row["FirstName"] == DBNull.Value ? "" : (string)row["FirstName"]) : ""),
                                    //LastName = (row.Table.Columns.Contains("LastName") ? (row["LastName"] == DBNull.Value ? "" : (string)row["LastName"]) : ""),
                                    //Sbin = true,
                                    //SGID = int.Parse(p.Group)
                        };
                        cSub.insert(cSub);
                        int intJobfcuntionID = int.Parse(row[2].ToString());

                        Model_ReportSectionItem sub = new Model_ReportSectionItem
                        {
                            ResultSectionID = 6,
                            Title           = row[3].ToString(),
                            Status          = true,
                            Priority        = count,
                            Code            = "T6" + count,
                            SUCID           = row[2].ToString(),
                            Short           = "",
                            Detail          = "",
                            PeopleTxt       = "",
                            CultureTxt      = "",
                            CompetitionTxt  = "",
                        };
                        sub.Insert(sub);

                        List <Model_JobFunctionListMain> cm1 = cm.GetAllActive();

                        int count1 = 4;
                        foreach (Model_JobFunctionListMain i1 in cm1.Where(o => o.Category == 1).OrderBy(o => o.Priority))
                        {
                            Model_JobFunctionListMap cj = new Model_JobFunctionListMap
                            {
                                JFID  = intJobfcuntionID,
                                JFMID = i1.JFMID,
                                Score = int.Parse(row[count1].ToString()),
                            };
                            cj.insert(cj);
                            count1 = count1 + 1;
                        }

                        int count2 = 22;
                        foreach (Model_JobFunctionListMain i2 in cm1.Where(o => o.Category == 2).OrderBy(o => o.Priority))
                        {
                            Model_JobFunctionListMap cj = new Model_JobFunctionListMap
                            {
                                JFID  = intJobfcuntionID,
                                JFMID = i2.JFMID,
                                Score = int.Parse(row[count2].ToString()),
                            };
                            cj.insert(cj);
                            count2 = count2 + 1;
                        }
                    }


                    count = count + 1;
                }
            }
        }



        Response.Redirect(Request.Url.ToString());
    }