Exemplo n.º 1
0
    //人員切換之後指定EmpID
    protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
    {
        RadioButton RadioButton1 = sender as RadioButton;

        RadioButton1.Checked = true;

        GridView_RegisterPeoplinfo.SelectedIndex = (RadioButton1.NamingContainer as GridViewRow).RowIndex;

        EmpID = GridView_RegisterPeoplinfo.DataKeys[GridView_RegisterPeoplinfo.SelectedIndex].Value.ToString();

        //載入個人資訊
        //個人固定欄位
        ObjectDataSource_fixA.SelectParameters["activity_id"].DefaultValue = ActivityID.ToString();
        ObjectDataSource_fixA.SelectParameters["emp_id"].DefaultValue      = EmpID;

        FormView_fixA.DataBind();

        //載入動態欄位資料

        ACMS.DAO.CustomFieldValueDAO myCustomFieldValueDAO = new ACMS.DAO.CustomFieldValueDAO();

        List <ACMS.VO.CustomFieldValueVO> myCustomFieldValueVOList = myCustomFieldValueDAO.SelectCustomFieldValue(ActivityID, EmpID);


        foreach (ACMS.VO.CustomFieldValueVO myCustomFieldValueVO in myCustomFieldValueVOList)
        {
            if (myCustomFieldValueVO.field_control.ToUpper() == "TEXTBOX")
            {
                TextBox MyControl = new TextBox();
                MyControl.ID = string.Format("txt{0}", myCustomFieldValueVO.field_id);
                (PlaceHolder1.FindControl(MyControl.ID) as TextBox).Text = myCustomFieldValueVO.field_value;
            }
            else if (myCustomFieldValueVO.field_control.ToUpper() == "TEXTBOXLIST")
            {
                TCheckBoxList MyControl = new TCheckBoxList();
                MyControl.ID = string.Format("plh{0}", myCustomFieldValueVO.field_id);
                (PlaceHolder1.FindControl(MyControl.ID) as TCheckBoxList).SelectedValueList = myCustomFieldValueVO.field_value;

                CheckBoxList1_SelectedIndexChanged((PlaceHolder1.FindControl(MyControl.ID) as TCheckBoxList), null);
            }
            else if (myCustomFieldValueVO.field_control.ToUpper() == "CHECKBOXLIST")
            {
                TCheckBoxList MyControl = new TCheckBoxList();

                MyControl.ID = string.Format("cbl{0}", myCustomFieldValueVO.field_id);
                (PlaceHolder1.FindControl(MyControl.ID) as TCheckBoxList).SelectedValueList = myCustomFieldValueVO.field_value;
            }
            else if (myCustomFieldValueVO.field_control.ToUpper() == "RADIOBUTTONLIST")
            {
                TRadioButtonList MyControl = new TRadioButtonList();
                MyControl.ID = string.Format("radl{0}", myCustomFieldValueVO.field_id);
                (MyControl as TRadioButtonList).ClearSelection();
                (PlaceHolder1.FindControl(MyControl.ID) as TRadioButtonList).SelectedValue = myCustomFieldValueVO.field_value;
            }
        }
    }
Exemplo n.º 2
0
    public string GetCustomField(string guid, string boss_id)
    {
        ACMS.DAO.CustomFieldValueDAO      myCustFieldValueDAO      = new ACMS.DAO.CustomFieldValueDAO();
        List <ACMS.VO.CustomFieldValueVO> myCustomFieldValueVOList = myCustFieldValueDAO.SelectCustomFieldValue(new Guid(guid), boss_id);

        ACMS.BO.CustomFieldItemBO        myCustFieldItemBO = new ACMS.BO.CustomFieldItemBO();
        List <ACMS.VO.CustomFieldItemVO> custFieldItemList;
        string  custFieldSt = "";
        decimal ttl         = 0;

        string[] FieldIDs;

        foreach (ACMS.VO.CustomFieldValueVO custFieldVO in myCustomFieldValueVOList)
        {
            if (custFieldVO.field_control.ToLower() == "textbox")
            {
                custFieldSt += custFieldVO.field_name + ":" + custFieldVO.field_value + "";
            }
            if (custFieldVO.field_control.ToLower() == "textboxlist")
            {
                ttl          = 0;
                custFieldSt += custFieldVO.field_name + ":";

                FieldIDs          = custFieldVO.field_value.Split(',');
                custFieldItemList = myCustFieldItemBO.SelectByField_id(custFieldVO.field_id);
                foreach (string fieldID in FieldIDs)
                {
                    foreach (ACMS.VO.CustomFieldItemVO custFieldItem in custFieldItemList)
                    {
                        if (int.Parse(fieldID) == custFieldItem.field_item_id)
                        {
                            custFieldSt += custFieldItem.field_item_name + ":" + custFieldItem.field_item_text + "";
                            ttl         += decimal.Parse(custFieldItem.field_item_text);
                        }
                    }
                }

                custFieldSt += "合計: " + ttl.ToString() + "";
            }
            if (custFieldVO.field_control.ToLower() == "checkboxlist")
            {
                custFieldSt += custFieldVO.field_name + ":";

                FieldIDs          = custFieldVO.field_value.Split(',');
                custFieldItemList = myCustFieldItemBO.SelectByField_id(custFieldVO.field_id);
                foreach (string fieldID in FieldIDs)
                {
                    foreach (ACMS.VO.CustomFieldItemVO custFieldItem in custFieldItemList)
                    {
                        if (int.Parse(fieldID) == custFieldItem.field_item_id)
                        {
                            custFieldSt += custFieldItem.field_item_name + custFieldItem.field_item_text + ",";
                        }
                    }
                }
                custFieldSt += "";
            }
            if (custFieldVO.field_control.ToLower() == "radiobuttonlist")
            {
                custFieldSt += custFieldVO.field_name + ":";

                FieldIDs          = custFieldVO.field_value.Split(',');
                custFieldItemList = myCustFieldItemBO.SelectByField_id(custFieldVO.field_id);
                foreach (string fieldID in FieldIDs)
                {
                    foreach (ACMS.VO.CustomFieldItemVO custFieldItem in custFieldItemList)
                    {
                        if (int.Parse(fieldID) == custFieldItem.field_item_id)
                        {
                            custFieldSt += custFieldItem.field_item_name + custFieldItem.field_item_text + ",";
                        }
                    }
                }
                custFieldSt += "";
            }
        }

        return(custFieldSt);
    }
Exemplo n.º 3
0
    //匯出名單
    protected void lbtnExport_Click(object sender, EventArgs e)
    {
        try
        {
            string activity_id   = GridView1.DataKeys[((sender as LinkButton).NamingContainer as GridViewRow).RowIndex].Values[0].ToString();
            string activity_type = GridView1.DataKeys[((sender as LinkButton).NamingContainer as GridViewRow).RowIndex].Values[1].ToString();

            //「匯出名單」的功能需帶出「報名編號(團隊編號)、部門、工號、姓名、分機、e-mail與額外填寫欄位」等欄位資訊

            DataTable table = new DataTable();

            ACMS.DAO.ActivityRegistDAO myActivityRegistDAO = new ACMS.DAO.ActivityRegistDAO();
            table = myActivityRegistDAO.SelectEmployeesByID(new Guid(activity_id), activity_type);
            if (table.Rows.Count == 0)
            {
                clsMyObj.ShowMessage("沒有資料");
                return;
            }


            DataTable dt = new DataTable();


            dt.Columns.Add("報名編號", System.Type.GetType("System.String"));
            dt.Columns.Add("部門代號", System.Type.GetType("System.String"));
            dt.Columns.Add("部門", System.Type.GetType("System.String"));
            dt.Columns.Add("工號", System.Type.GetType("System.String"));
            dt.Columns.Add("姓名", System.Type.GetType("System.String"));
            dt.Columns.Add("分機", System.Type.GetType("System.String"));
            dt.Columns.Add("EMAIL", System.Type.GetType("System.String"));
            dt.Columns.Add("進度狀態", System.Type.GetType("System.String"));
            //=================================================================
            ACMS.DAO.CustomFieldValueDAO myCustFieldValueDAO = new ACMS.DAO.CustomFieldValueDAO();


            List <ACMS.VO.CustomFieldValueVO> myCustomFieldValueVOList;
            if (table.Rows[0]["activity_type"].ToString() == "2")
            {
                myCustomFieldValueVOList = myCustFieldValueDAO.SelectCustomFieldValue(new Guid(table.Rows[0]["id"].ToString()), table.Rows[0]["boss_id"].ToString());
                dt.Columns.Add("隊名", System.Type.GetType("System.String"));
            }
            else
            {
                myCustomFieldValueVOList = myCustFieldValueDAO.SelectCustomFieldValue(new Guid(table.Rows[0]["id"].ToString()), table.Rows[0]["emp_id"].ToString());
            }
            dt.Columns.Add("身份證_護照", System.Type.GetType("System.String"));
            ACMS.BO.CustomFieldItemBO        myCustFieldItemBO = new ACMS.BO.CustomFieldItemBO();
            List <ACMS.VO.CustomFieldItemVO> myFieldVOS;
            foreach (ACMS.VO.CustomFieldValueVO custFieldVO in myCustomFieldValueVOList)
            {
                if (custFieldVO.field_control.ToLower() == "textbox")
                {
                    dt.Columns.Add(custFieldVO.field_name, System.Type.GetType("System.String"));
                }

                if (custFieldVO.field_control.ToLower() == "textboxlist")
                {
                    myFieldVOS = myCustFieldItemBO.SelectByField_id(custFieldVO.field_id);
                    foreach (ACMS.VO.CustomFieldItemVO myFieldvo in myFieldVOS)
                    {
                        dt.Columns.Add(custFieldVO.field_name + '_' + myFieldvo.field_item_name, System.Type.GetType("System.Decimal"));
                    }
                    dt.Columns.Add(custFieldVO.field_name + "合計", System.Type.GetType("System.Decimal"));
                }
                if (custFieldVO.field_control.ToLower() == "radiobuttonlist")
                {
                    // dt.Columns.Add(custFieldVO.field_name, System.Type.GetType("System.String"));
                    myFieldVOS = myCustFieldItemBO.SelectByField_id(custFieldVO.field_id);
                    foreach (ACMS.VO.CustomFieldItemVO myFieldvo in myFieldVOS)
                    {
                        dt.Columns.Add(custFieldVO.field_name + '_' + myFieldvo.field_item_name, System.Type.GetType("System.String"));
                    }
                }
                if (custFieldVO.field_control.ToLower() == "checkboxlist")
                {
                    //dt.Columns.Add(custFieldVO.field_name, System.Type.GetType("System.String"));
                    myFieldVOS = myCustFieldItemBO.SelectByField_id(custFieldVO.field_id);
                    foreach (ACMS.VO.CustomFieldItemVO myFieldvo in myFieldVOS)
                    {
                        dt.Columns.Add(custFieldVO.field_name + '_' + myFieldvo.field_item_name, System.Type.GetType("System.String"));
                    }
                }
            }


            // dt.Columns.Add("自訂欄位", System.Type.GetType("System.String"));

            string  teamName = "";
            int     seqno    = 0;
            int     seqno1   = 0;
            DataRow dtDr;
            foreach (DataRow dr in table.Rows)
            {
                dtDr = dt.NewRow();
                if (dr["activity_type"].ToString() == "2")
                {
                    if (teamName != dr["boss_id"].ToString().Trim())
                    {
                        seqno++;
                    }
                    if (seqno > int.Parse(dr["team_max"].ToString()))
                    {
                        seqno1++;
                    }
                }
                else
                {
                    seqno++;
                    if (seqno > int.Parse(dr["team_max"].ToString()))
                    {
                        seqno1++;
                    }
                }
                if (seqno1 > 0)
                {
                    dtDr["報名編號"] = "備取:" + seqno1.ToString();
                }
                else
                {
                    dtDr["報名編號"] = "正取:" + seqno.ToString();
                }
                dtDr["部門代號"]   = dr["DEPT_ID"].ToString();
                dtDr["部門"]     = dr["C_DEPT_NAME"].ToString();
                dtDr["工號"]     = dr["WORK_ID"].ToString();
                dtDr["姓名"]     = dr["NATIVE_NAME"].ToString();
                dtDr["分機"]     = dr["OFFICE_PHONE"].ToString();
                dtDr["EMAIL"]  = dr["OFFICE_MAIL"].ToString();
                dtDr["進度狀態"]   = dr["check_status"].ToString();
                dtDr["身份證_護照"] = dr["idno"].ToString();
                if (dr["activity_type"].ToString() == "2")
                {
                    if (dr["boss_id"].ToString() != teamName)
                    {
                        // dtDr["自訂欄位"] = GetCustomField(dr["id"].ToString(), dr["boss_id"].ToString());
                        GetCustomFieldNew(dr["id"].ToString(), dr["boss_id"].ToString(), ref dtDr);
                        dtDr["隊名"] = dr["team_name"].ToString().Trim();
                    }


                    teamName = dr["boss_id"].ToString().Trim();
                }
                else
                {
                    // dtDr["自訂欄位"] = GetCustomField(dr["id"].ToString(), dr["emp_id"].ToString());
                    GetCustomFieldNew(dr["id"].ToString(), dr["emp_id"].ToString(), ref dtDr);
                }
                dt.Rows.Add(dtDr);
            }

            if (table != null && table.Rows.Count > 0)
            {
                table.Columns[0].ColumnName = "員工編號";
                table.Columns[1].ColumnName = "員工姓名";
                table.Columns[2].ColumnName = "員工部門";

                // 產生 Excel 資料流。
                //MemoryStream ms = DataTableRenderToExcel.RenderDataTableToExcel(table) as MemoryStream;
                MemoryStream ms = DataTableRenderToExcel.RenderDataTableToExcel(dt) as MemoryStream;
                // 設定強制下載標頭。
                Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}.xls", Server.UrlEncode("RegistedList")));
                // 輸出檔案。
                Response.BinaryWrite(ms.ToArray());

                ms.Close();
                ms.Dispose();
            }
            else
            {
                clsMyObj.ShowMessage("沒有資料!");
            }
        }
        catch (Exception ex)
        {
            WriteErrorLog("ExportExcel", ex.Message, "0");
        }
    }