protected void aspPager_PageChanged(object sender, EventArgs e)
 {
     if (hidCondition.Value != "")
     {
         condObj = JsonServiceBase.FromJson<HR_Scheduling>(hidCondition.Value);
     }
     BindList(condObj, aspPager.CurrentPageIndex);
 }
Exemple #2
0
 protected void aspPager_PageChanged(object sender, EventArgs e)
 {
     if (hidCondition.Value != "")
     {
         condObj = JsonServiceBase.FromJson <HR_Scheduling>(hidCondition.Value);
     }
     BindList(condObj, aspPager.CurrentPageIndex);
 }
Exemple #3
0
 protected void btnSetPageSize_Click(object sender, EventArgs e)
 {
     aspPager.PageSize = int.Parse(txtPageSize.Value);
     if (hidCondition.Value != "")
     {
         condObj = JsonServiceBase.FromJson <HR_Scheduling>(hidCondition.Value);
     }
     BindList(condObj, aspPager.CurrentPageIndex);
 }
 protected void btnSetPageSize_Click(object sender, EventArgs e)
 {
     aspPager.PageSize = int.Parse(txtPageSize.Value);
     if (hidCondition.Value != "")
     {
         condObj = JsonServiceBase.FromJson<HR_Scheduling>(hidCondition.Value);
     }
     BindList(condObj, aspPager.CurrentPageIndex);
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        //在列表里点击删除按钮,通过AJAX执行这里的后台代码,删除一条记录
        if (Request["DelDay"] != null)
        {
            int re = BLLTable <HR_Scheduling> .Factory(conn).Delete(HR_Scheduling.Attribute.SchDay, Request["DelDay"]);

            if (re > 0)
            {
                Response.Write("1");//可以输出数字 大于0 表示操作成功,也可以直接输出 字符串,客户端将弹出此字符串信息作为提示
            }
            else
            {
                Response.Write("删除失败!");
            }
        }

        //在列表顶部点击删除按钮,通过AJAX执行这里的后台代码,删除多条记录
        if (Request["DelKeyIDS"] != null)
        {
            HR_Scheduling cond = new HR_Scheduling();
            cond.In(HR_Scheduling.Attribute.SchDay, Request["DelKeyIDS"]);
            int re = BLLTable <HR_Scheduling> .Factory(conn).Delete(cond);

            if (re > 0)
            {
                Response.Write("1");//可以输出数字 大于0 表示操作成功,也可以直接输出 字符串,客户端将弹出此字符串信息作为提示
            }
            else
            {
                Response.Write("删除失败!");
            }
        }

        //在用户详细信息查看编辑页面,点保存时,通过AJAX执行这里的后台代码,实现部门字段的更新
        if (Request["saveInfo"] != null)
        {
            HR_Scheduling val = new HR_Scheduling();
            val.SchDay = Int16.Parse(Request["FieldKeyID"]);
            List <AttributeItem> lstCol = val.af_AttributeItemList;
            for (int i = 0; i < lstCol.Count; i++)
            {
                if (!string.IsNullOrEmpty(Request["txt" + lstCol[i].FieldName]))
                {
                    val.SetValue(lstCol[i].FieldName, Request["txt" + lstCol[i].FieldName]);
                }
            }

            BLLTable <HR_Scheduling> .Factory(conn).Update(val, HR_Scheduling.Attribute.SchDay);

            Response.Write("修改用户信息成功");
        }
        Response.End();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //���б�����ɾ����ť��ͨ��AJAXִ������ĺ�̨���룬ɾ��һ����¼
        if (Request["DelDay"] != null)
        {
            int re = BLLTable<HR_Scheduling>.Factory(conn).Delete(HR_Scheduling.Attribute.SchDay, Request["DelDay"]);
            if (re > 0)
            {
                Response.Write("1");//����������� ����0 ��ʾ�����ɹ���Ҳ����ֱ����� �ַ������ͻ��˽��������ַ�����Ϣ��Ϊ��ʾ
            }
            else
            {
                Response.Write("ɾ��ʧ�ܣ�");
            }
        }

        //���б�������ɾ����ť��ͨ��AJAXִ������ĺ�̨���룬ɾ��������¼
        if (Request["DelKeyIDS"] != null)
        {
            HR_Scheduling cond = new HR_Scheduling();
            cond.In(HR_Scheduling.Attribute.SchDay, Request["DelKeyIDS"]);
            int re = BLLTable<HR_Scheduling>.Factory(conn).Delete(cond);
            if (re > 0)
            {
                Response.Write("1");//����������� ����0 ��ʾ�����ɹ���Ҳ����ֱ����� �ַ������ͻ��˽��������ַ�����Ϣ��Ϊ��ʾ
            }
            else
            {
                Response.Write("ɾ��ʧ�ܣ�");
            }
        }

        //���û���ϸ��Ϣ�鿴�༭ҳ�棬�㱣��ʱ��ͨ��AJAXִ������ĺ�̨���룬ʵ�ֲ����ֶεĸ���
        if (Request["saveInfo"] != null)
        {
            HR_Scheduling val = new HR_Scheduling();
            val.SchDay = Int16.Parse(Request["FieldKeyID"]);
            List<AttributeItem> lstCol = val.af_AttributeItemList;
            for (int i = 0; i < lstCol.Count; i++)
            {
                if (!string.IsNullOrEmpty(Request["txt" + lstCol[i].FieldName])) {
                    val.SetValue(lstCol[i].FieldName,Request["txt" + lstCol[i].FieldName]);
                }
            }

            BLLTable<HR_Scheduling>.Factory(conn).Update(val, HR_Scheduling.Attribute.SchDay);
            Response.Write("�޸��û���Ϣ�ɹ�");

        }
        Response.End();
    }
Exemple #7
0
    private void BindList(HR_Scheduling condObj, int curPage)
    {
        if (condObj.af_PageByAttributeItem == null)//如果不存在用户定义的分页排序属性,则用主键属性排序
        {
            condObj.af_PageBy(HR_Scheduling.Attribute.SchDay, Order.Desc);
        }

        #region//数据权限条件

        #endregion
        //condObj.PID = decimal.Parse(pid);

        listObj = BLLTable <HR_Scheduling> .Factory(conn).SelectByPage(valObj, condObj, aspPager.PageSize, curPage, ref recount);

        repList.DataSource = listObj;
        repList.DataBind();
        aspPager.RecordCount = recount;
    }
Exemple #8
0
    protected void btnFind_Click(object sender, EventArgs e)
    {
        condObj = new HR_Scheduling();



        if (txtYear.Value != "")
        {
            condObj.Like(HR_Scheduling.Attribute.SchYear, Convert.ToInt32(txtYear.Value));
        }


        if (txtMonth.Value != "")
        {
            condObj.Like(HR_Scheduling.Attribute.SchMonth, Convert.ToInt16(txtMonth.Value));
        }


        if (txtDay.Value != "")
        {
            condObj.Like(HR_Scheduling.Attribute.SchDay, Convert.ToInt16(txtDay.Value));
        }


        if (txtType.Value != "")
        {
            condObj.SchType = Convert.ToInt32(txtType.Value);
        }


        if (txtSchClassid.Value != "")
        {
            condObj.Like(HR_Scheduling.Attribute.SchClassid, Convert.ToInt32(txtSchClassid.Value));
        }

        hidCondition.Value = condObj.ToJson(20);

        BindList(condObj, 1);
    }
    protected void btnFind_Click(object sender, EventArgs e)
    {
        condObj = new HR_Scheduling();

        if(txtYear.Value !="" )
            condObj.Like(HR_Scheduling.Attribute.SchYear, Convert.ToInt32(txtYear.Value));

        if(txtMonth.Value !="" )
            condObj.Like(HR_Scheduling.Attribute.SchMonth, Convert.ToInt16(txtMonth.Value));

        if(txtDay.Value !="" )
            condObj.Like(HR_Scheduling.Attribute.SchDay, Convert.ToInt16(txtDay.Value));

        if(txtType.Value !="" )
            condObj.SchType = Convert.ToInt32(txtType.Value);

        if(txtSchClassid.Value !="" )
            condObj.Like(HR_Scheduling.Attribute.SchClassid, Convert.ToInt32(txtSchClassid.Value));

        hidCondition.Value = condObj.ToJson(20);

        BindList(condObj, 1);
    }
Exemple #10
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        string wran = "";

        litWarn.Visible = false;

        //值班类型设置
        string wdTypeHtml = tbyWorkDayType.InnerHtml;

        string[] wdTypeStrs = wdTypeHtml.ToLower().Contains("<tr>") ? wdTypeHtml.ToLower().Substring(wdTypeHtml.ToLower().IndexOf("<tr>")).Split(new string[] { "<tr>" }, StringSplitOptions.RemoveEmptyEntries) : new string[0];
        Dictionary <DateTime, int> dicWdType = new Dictionary <DateTime, int>();

        foreach (string wdTStr in wdTypeStrs)
        {
            string[] tds = wdTStr.ToLower().Substring(wdTStr.ToLower().IndexOf("<td>")).Split(new string[] { "<td>" }, StringSplitOptions.RemoveEmptyEntries);
            if (tds.Length < 3)
            {
                continue;
            }
            DateTime sd = DateTime.MinValue;
            DateTime ed = DateTime.MinValue;
            int      ty = -1;
            if (!DateTime.TryParse(tds[0].Remove(tds[0].IndexOf('<'), tds[0].Length - tds[0].IndexOf('<')), out sd) || !DateTime.TryParse(tds[1].Remove(tds[1].IndexOf('<'), tds[1].Length - tds[1].IndexOf('<')), out ed) || !int.TryParse(tds[2].Remove(tds[2].IndexOf('<'), tds[2].Length - tds[2].IndexOf('<')), out ty))
            {
                continue;
            }
            sd = sd.Date;
            ed = ed.Date;
            while (sd <= ed)
            {
                if (!dicWdType.ContainsKey(sd))
                {
                    dicWdType.Add(sd, ty);
                }
                else
                {
                    dicWdType[sd] = ty;
                }
                sd = sd.AddDays(1);
            }
        }
        //休息日设置
        string[] weekStr = txtXiuXi.Value.Split(new char[] { ',', ',', ' ', ' ' }, StringSplitOptions.RemoveEmptyEntries);
        //是否 周一到周7之间
        bool isAllRight = true;

        int[] week = new int[weekStr.Length];
        for (int i = 0; i < weekStr.Length; i++)
        {
            if (!int.TryParse(weekStr[i].Replace(" ", ""), out week[i]))
            {
                isAllRight = false;
            }
            else if (week[i] < 1 || week[i] > 7)
            {
                isAllRight = false;
            }
        }

        HR_Scheduling_IniProject proj = new HR_Scheduling_IniProject();

        proj.WorkDayType = wdTypeHtml;
        proj.XiuXi       = txtXiuXi.Value;
        proj.ProjectName = txtProjectName.Value;
        if (chkFuGai.Checked)
        {
            proj.FuGaiOrZengBu = 1;
        }
        else
        {
            proj.FuGaiOrZengBu = 2;
        }
        if (isAllRight)
        {
            string   delschWhere = " 1=1 ";
            HR_STAFF stfVal      = new HR_STAFF();
            stfVal.STAFF_ID = 0;
            HR_STAFF stfCon = new HR_STAFF();
            if (!string.IsNullOrEmpty(hidstaffid.Value.Trim()))
            {
                stfCon.STAFF_ID = decimal.Parse(hidstaffid.Value);
                delschWhere    += " and HR_STAFF.STAFF_ID = " + stfCon.STAFF_ID;

                proj.StaffID = stfCon.STAFF_ID.ToString();
            }
            else if (!string.IsNullOrEmpty(hiddeptid.Value.Trim()))
            {
                stfCon.Like(HR_STAFF.Attribute.DEPT_ID, hiddeptid.Value);
                delschWhere += " and HR_STAFF.DEPT_ID like '" + hiddeptid.Value + "%'";

                proj.DeptID = stfCon.DEPT_ID;
            }
            else if (!string.IsNullOrEmpty(hidorgid.Value.Trim()))
            {
                stfCon.Like(HR_STAFF.Attribute.ORG_ID, hidorgid.Value);
                delschWhere += " and HR_STAFF.ORG_ID like '" + hidorgid.Value + "%'";

                proj.OrgID = stfCon.ORG_ID;
            }
            else
            {
                stfCon.STAFF_ID = userBase.StaffID;
                delschWhere    += " and HR_STAFF.STAFF_ID = " + userBase.StaffID;

                proj.StaffID = stfCon.STAFF_ID.ToString();
            }
            List <HR_STAFF> stffs = BLLTable <HR_STAFF> .Factory(conn).Select(stfVal, stfCon);

            //外部传入选中的班次id
            string[] schidstr = hidSelBanciId.Value.TrimEnd(',').Split(',');
            proj.SelBanciId = hidSelBanciId.Value;
            List <int> schids = new List <int>();
            for (int i = 0; i < schidstr.Length; i++)
            {
                int sid = -1;
                if (int.TryParse(schidstr[i], out sid))
                {
                    schids.Add(sid);
                }
            }
            int stfCount = 0;
            int stfSch   = 0;
            //开始时间
            DateTime sDate = DateTime.Parse(txtStartTime.Value);
            proj.StartTime = sDate;
            //结束时间
            DateTime eDate = DateTime.Parse(txtEndTime.Value);
            proj.EndTime = eDate;

            DateTime dt = sDate;
            //找出班次
            List <HR_Scheduling> schList = new List <HR_Scheduling>();
            foreach (HR_STAFF stf in stffs)
            {
                stfCount++;
                dt = sDate;
                while (dt.Date <= eDate.Date)
                {
                    foreach (int schid in schids)
                    {
                        HR_Scheduling sch = new HR_Scheduling();
                        sch._SchYear  = dt.Date.Year;
                        sch._SchMonth = Convert.ToInt16(dt.Date.Month);
                        sch._SchDay   = Convert.ToInt16(dt.Date.Day);
                        sch._STAFF_ID = Convert.ToInt32(stf.STAFF_ID);
                        sch._SchType  = week.Contains(CheckInOutHelper.IndexOfWeekByEnWeek(dt)) ? 3 : 1;
                        if (dicWdType.ContainsKey(dt.Date))
                        {
                            sch._SchType = dicWdType[dt.Date];
                        }
                        sch._SchClassid = schid;
                        schList.Add(sch);
                    }
                    dt = dt.AddDays(1);
                    stfSch++;
                }
            }
            int buildCount = 0;
            int delsCount  = 0;
            if (chkFuGai.Checked)
            {
                //HR_Scheduling delCon = new HR_Scheduling();
                //delCon.Top(1000);
                //string wher = " CAST(CAST({0} AS char(4)) + '-' + CAST({1} AS char(2)) + '-' + CAST({2} AS char(2)) as datetime) >= '{3}-{4}-{5}' and CAST(CAST({6} AS char(4)) + '-' + CAST({7} AS char(2)) + '-' + CAST({8} AS char(2)) as datetime) <= '{9}-{10}-{11}' ";
                //delCon.Where(wher, HR_Scheduling.Attribute.SchYear, HR_Scheduling.Attribute.SchMonth, HR_Scheduling.Attribute.SchDay,
                //                sDate.Year, sDate.Month, sDate.Day,
                //                HR_Scheduling.Attribute.SchYear, HR_Scheduling.Attribute.SchMonth, HR_Scheduling.Attribute.SchDay,
                //                eDate.Year, eDate.Month, eDate.Day);
                //Relation rt = new Relation(HR_STAFF.Attribute.STAFF_ID, HR_Scheduling.Attribute.STAFF_ID);
                //rt.AddCondition(stfCon);
                //while (BLLTable<HR_Scheduling>.Factory(conn).Delete(delCon, rt) > 0)
                //{
                //    continue;
                //}
                string wher = " delete top(1000) " +
                              " from HR_Scheduling " +
                              " where CAST(CAST({0} AS char(4)) + '-' + CAST({1} AS char(2)) + '-' + CAST({2} AS char(2)) as datetime) >= '{3}-{4}-{5}' and CAST(CAST({6} AS char(4)) + '-' + CAST({7} AS char(2)) + '-' + CAST({8} AS char(2)) as datetime) <= '{9}-{10}-{11}' " +
                              " and HR_Scheduling.staff_id in (select hr_staff.staff_id from hr_staff where " + delschWhere + ")";
                wher = string.Format(wher, HR_Scheduling.Attribute.SchYear, HR_Scheduling.Attribute.SchMonth, HR_Scheduling.Attribute.SchDay,
                                     sDate.Year, sDate.Month, sDate.Day,
                                     HR_Scheduling.Attribute.SchYear, HR_Scheduling.Attribute.SchMonth, HR_Scheduling.Attribute.SchDay,
                                     eDate.Year, eDate.Month, eDate.Day);
                int delCount = BLLTable.ExecSQL(new HR_Scheduling(), wher, CommandType.Text);
                while (delCount > 0)
                {
                    delsCount += delCount;
                    delCount   = BLLTable.ExecSQL(new HR_Scheduling(), wher, CommandType.Text);
                    continue;
                }
                DataTable dataTable = BLLTable <HR_Scheduling> .qDataTable("select * from " + HR_Scheduling.Attribute.SchDay.TableName + " where 1=2");

                List <DataRow> dataList = new List <DataRow>();
                foreach (HR_Scheduling sch in schList)
                {
                    DataRow dr = dataTable.NewRow();
                    foreach (DataColumn dc in dataTable.Columns)
                    {
                        dr[dc] = sch.GetValue(new AttributeItem(HR_Scheduling.Attribute.STAFF_ID.TableName, dc.ColumnName));
                    }
                    dataList.Add(dr);
                }

                try
                {
                    //将电量数据批量插入数据库
                    SqlBulkCopy sbc = new SqlBulkCopy(MyConfigurationSettings.GetValue("conn"));
                    sbc.BatchSize            = 1000;
                    sbc.BulkCopyTimeout      = (((dataList.Count) / 1000) + 1) * 3;
                    sbc.DestinationTableName = HR_Scheduling.Attribute.STAFF_ID.TableName;
                    sbc.WriteToServer(dataList.ToArray());
                    buildCount += dataList.Count;
                }
                catch { }
            }
            else
            {
                foreach (HR_Scheduling sch in schList)
                {
                    if (!BLLTable <HR_Scheduling> .Exists(sch))
                    {
                        buildCount += BLLTable <HR_Scheduling> .Factory(conn).Insert(sch, HR_Scheduling.Attribute.ID);
                    }
                }
            }
            int ret2 = BLLTable <HR_Scheduling_IniProject> .Factory(conn).Insert(proj, HR_Scheduling_IniProject.Attribute.ID);

            litScript.Text = "<script>alert('生成成功!" + (chkFuGai.Checked ? "覆盖" : "增补") + "生成" + buildCount + "条记录!删除" + delsCount
                             + "条记录,保存" + ret2 + "个配置方案"
                             + "');$('.main').unmask();</script>";
        }
        else
        {
            wran = "休息日输入有误!请参考提示输入。";
        }

        if (!string.IsNullOrEmpty(wran))
        {
            litWarn.Text    = wran;
            litWarn.Visible = true;
            litScript.Text  = "<script>alert('" + wran + "');$('.main').unmask();</script>";
        }
    }
Exemple #11
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        try
        {
            HR_STAFF stfVal = new HR_STAFF();
            stfVal.STAFF_ID = 0;
            List <HR_STAFF> stffs = BLLTable <HR_STAFF> .Factory(conn).Select(stfVal, new HR_STAFF());

            string[]   schidstr = hidSelBanciId.Value.TrimEnd(',').Split(',');
            List <int> schids   = new List <int>();
            for (int i = 0; i < schidstr.Length; i++)
            {
                int sid = -1;
                if (int.TryParse(schidstr[i], out sid))
                {
                    schids.Add(sid);
                }
            }
            int                  stfCount = 0;
            int                  stfSch   = 0;
            DateTime             sDate    = DateTime.Parse(txtStartTime.Value);
            DateTime             eDate    = DateTime.Parse(txtEndTime.Value);
            DateTime             dt       = sDate;
            List <HR_Scheduling> schList  = new List <HR_Scheduling>();
            foreach (HR_STAFF stf in stffs)
            {
                stfCount++;
                dt = sDate;
                while (dt.Date <= eDate.Date)
                {
                    foreach (int schid in schids)
                    {
                        HR_Scheduling sch = new HR_Scheduling();
                        sch._SchYear    = dt.Date.Year;
                        sch._SchMonth   = Convert.ToInt16(dt.Date.Month);
                        sch._SchDay     = Convert.ToInt16(dt.Date.Day);
                        sch._STAFF_ID   = Convert.ToInt32(stf.STAFF_ID);
                        sch._SchType    = Convert.ToInt32(txtType.Value);
                        sch._SchClassid = schid;
                        schList.Add(sch);
                    }
                    dt = dt.AddDays(1);
                    stfSch++;
                }
            }
            int           buildCount = 0;
            HR_Scheduling delCon     = new HR_Scheduling();
            delCon.Top(500);
            string wher = " CAST(CAST({0} AS char(4)) + '-' + CAST({1} AS char(2)) + '-' + CAST({2} AS char(2)) as datetime) >= '{3}-{4}-{5}' and CAST(CAST({6} AS char(4)) + '-' + CAST({7} AS char(2)) + '-' + CAST({8} AS char(2)) as datetime) <= '{9}-{10}-{11}' ";
            delCon.Where(wher, HR_Scheduling.Attribute.SchYear, HR_Scheduling.Attribute.SchMonth, HR_Scheduling.Attribute.SchDay,
                         sDate.Year, sDate.Month, sDate.Day,
                         HR_Scheduling.Attribute.SchYear, HR_Scheduling.Attribute.SchMonth, HR_Scheduling.Attribute.SchDay,
                         eDate.Year, eDate.Month, eDate.Day);
            while (BLLTable <HR_Scheduling> .Factory(conn).Delete(delCon) > 0)
            {
                continue;
            }
            DataTable dataTable = BLLTable <HR_Scheduling> .qDataTable("select * from " + HR_Scheduling.Attribute.SchDay.TableName + " where 1=2");

            List <DataRow> dataList = new List <DataRow>();
            foreach (HR_Scheduling sch in schList)
            {
                DataRow dr = dataTable.NewRow();
                foreach (DataColumn dc in dataTable.Columns)
                {
                    dr[dc] = sch.GetValue(new AttributeItem(HR_Scheduling.Attribute.STAFF_ID.TableName, dc.ColumnName));
                }
                dataList.Add(dr);
            }

            try
            {
                //将电量数据批量插入数据库
                SqlBulkCopy sbc = new SqlBulkCopy(MyConfigurationSettings.GetValue("conn"));
                sbc.BatchSize            = 1000;
                sbc.BulkCopyTimeout      = (((dataList.Count) / 1000) + 1) * 3;
                sbc.DestinationTableName = HR_Scheduling.Attribute.STAFF_ID.TableName;
                sbc.WriteToServer(dataList.ToArray());
                buildCount += dataList.Count;
            }
            catch { }
            ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "$('.main').unmask();alert('成功修改" + buildCount + "条记录');", true);
        }
        catch (Exception ex)
        {
            litWarn.Text = ex.Message;
        }
    }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        string wran = "";
        litWarn.Visible = false;

        //值班类型设置
        string wdTypeHtml = tbyWorkDayType.InnerHtml;
        string[] wdTypeStrs = wdTypeHtml.ToLower().Contains("<tr>") ? wdTypeHtml.ToLower().Substring(wdTypeHtml.ToLower().IndexOf("<tr>")).Split(new string[] { "<tr>" }, StringSplitOptions.RemoveEmptyEntries) : new string[0];
        Dictionary<DateTime, int> dicWdType = new Dictionary<DateTime, int>();
        foreach (string wdTStr in wdTypeStrs)
        {
            string[] tds = wdTStr.ToLower().Substring(wdTStr.ToLower().IndexOf("<td>")).Split(new string[] { "<td>" }, StringSplitOptions.RemoveEmptyEntries);
            if (tds.Length < 3)
                continue;
            DateTime sd = DateTime.MinValue;
            DateTime ed = DateTime.MinValue;
            int ty = -1;
            if (!DateTime.TryParse(tds[0].Remove(tds[0].IndexOf('<'), tds[0].Length - tds[0].IndexOf('<')), out sd) || !DateTime.TryParse(tds[1].Remove(tds[1].IndexOf('<'), tds[1].Length - tds[1].IndexOf('<')), out ed) || !int.TryParse(tds[2].Remove(tds[2].IndexOf('<'), tds[2].Length - tds[2].IndexOf('<')), out ty))
                continue;
            sd = sd.Date;
            ed = ed.Date;
            while (sd <= ed)
            {
                if (!dicWdType.ContainsKey(sd))
                    dicWdType.Add(sd, ty);
                else
                    dicWdType[sd] = ty;
                sd = sd.AddDays(1);
            }
        }
        //休息日设置
        string[] weekStr = txtXiuXi.Value.Split(new char[] { ',', ',', ' ', ' ' }, StringSplitOptions.RemoveEmptyEntries);
        //是否 周一到周7之间
        bool isAllRight = true;
        int[] week = new int[weekStr.Length];
        for (int i = 0; i < weekStr.Length; i++)
        {
            if (!int.TryParse(weekStr[i].Replace(" ", ""), out week[i]))
                isAllRight = false;
            else if (week[i] < 1 || week[i] > 7)
                isAllRight = false;
        }

        HR_Scheduling_IniProject proj = new HR_Scheduling_IniProject();
        proj.WorkDayType = wdTypeHtml;
        proj.XiuXi = txtXiuXi.Value;
        proj.ProjectName = txtProjectName.Value;
        if (chkFuGai.Checked)
            proj.FuGaiOrZengBu = 1;
        else
            proj.FuGaiOrZengBu = 2;
        if (isAllRight)
        {
            string delschWhere = " 1=1 ";
            HR_STAFF stfVal = new HR_STAFF();
            stfVal.STAFF_ID = 0;
            HR_STAFF stfCon = new HR_STAFF();
            if (!string.IsNullOrEmpty(hidstaffid.Value.Trim()))
            {
                stfCon.STAFF_ID = decimal.Parse(hidstaffid.Value);
                delschWhere += " and HR_STAFF.STAFF_ID = " + stfCon.STAFF_ID;

                proj.StaffID = stfCon.STAFF_ID.ToString();
            }
            else if (!string.IsNullOrEmpty(hiddeptid.Value.Trim()))
            {
                stfCon.Like(HR_STAFF.Attribute.DEPT_ID, hiddeptid.Value);
                delschWhere += " and HR_STAFF.DEPT_ID like '" + hiddeptid.Value + "%'";

                proj.DeptID = stfCon.DEPT_ID;
            }
            else if (!string.IsNullOrEmpty(hidorgid.Value.Trim()))
            {
                stfCon.Like(HR_STAFF.Attribute.ORG_ID, hidorgid.Value);
                delschWhere += " and HR_STAFF.ORG_ID like '" + hidorgid.Value + "%'";

                proj.OrgID = stfCon.ORG_ID;
            }
            else
            {
                stfCon.STAFF_ID = userBase.StaffID;
                delschWhere += " and HR_STAFF.STAFF_ID = " + userBase.StaffID;

                proj.StaffID = stfCon.STAFF_ID.ToString();
            }
            List<HR_STAFF> stffs = BLLTable<HR_STAFF>.Factory(conn).Select(stfVal, stfCon);
            //外部传入选中的班次id
            string[] schidstr = hidSelBanciId.Value.TrimEnd(',').Split(',');
            proj.SelBanciId = hidSelBanciId.Value;
            List<int> schids = new List<int>();
            for (int i = 0; i < schidstr.Length; i++)
            {
                int sid = -1;
                if (int.TryParse(schidstr[i], out sid))
                    schids.Add(sid);
            }
            int stfCount = 0;
            int stfSch = 0;
            //开始时间
            DateTime sDate = DateTime.Parse(txtStartTime.Value);
            proj.StartTime = sDate;
            //结束时间
            DateTime eDate = DateTime.Parse(txtEndTime.Value);
            proj.EndTime = eDate;

            DateTime dt = sDate;
            //找出班次
            List<HR_Scheduling> schList = new List<HR_Scheduling>();
            foreach (HR_STAFF stf in stffs)
            {
                stfCount++;
                dt = sDate;
                while (dt.Date <= eDate.Date)
                {
                    foreach (int schid in schids)
                    {
                        HR_Scheduling sch = new HR_Scheduling();
                        sch._SchYear = dt.Date.Year;
                        sch._SchMonth = Convert.ToInt16(dt.Date.Month);
                        sch._SchDay = Convert.ToInt16(dt.Date.Day);
                        sch._STAFF_ID = Convert.ToInt32(stf.STAFF_ID);
                        sch._SchType = week.Contains(CheckInOutHelper.IndexOfWeekByEnWeek(dt)) ? 3 : 1;
                        if (dicWdType.ContainsKey(dt.Date))
                            sch._SchType = dicWdType[dt.Date];
                        sch._SchClassid = schid;
                        schList.Add(sch);
                    }
                    dt = dt.AddDays(1);
                    stfSch++;
                }
            }
            int buildCount = 0;
            int delsCount = 0;
            if (chkFuGai.Checked)
            {
                //HR_Scheduling delCon = new HR_Scheduling();
                //delCon.Top(1000);
                //string wher = " CAST(CAST({0} AS char(4)) + '-' + CAST({1} AS char(2)) + '-' + CAST({2} AS char(2)) as datetime) >= '{3}-{4}-{5}' and CAST(CAST({6} AS char(4)) + '-' + CAST({7} AS char(2)) + '-' + CAST({8} AS char(2)) as datetime) <= '{9}-{10}-{11}' ";
                //delCon.Where(wher, HR_Scheduling.Attribute.SchYear, HR_Scheduling.Attribute.SchMonth, HR_Scheduling.Attribute.SchDay,
                //                sDate.Year, sDate.Month, sDate.Day,
                //                HR_Scheduling.Attribute.SchYear, HR_Scheduling.Attribute.SchMonth, HR_Scheduling.Attribute.SchDay,
                //                eDate.Year, eDate.Month, eDate.Day);
                //Relation rt = new Relation(HR_STAFF.Attribute.STAFF_ID, HR_Scheduling.Attribute.STAFF_ID);
                //rt.AddCondition(stfCon);
                //while (BLLTable<HR_Scheduling>.Factory(conn).Delete(delCon, rt) > 0)
                //{
                //    continue;
                //}
                string wher = " delete top(1000) " +
                              " from HR_Scheduling " +
                              " where CAST(CAST({0} AS char(4)) + '-' + CAST({1} AS char(2)) + '-' + CAST({2} AS char(2)) as datetime) >= '{3}-{4}-{5}' and CAST(CAST({6} AS char(4)) + '-' + CAST({7} AS char(2)) + '-' + CAST({8} AS char(2)) as datetime) <= '{9}-{10}-{11}' " +
                              " and HR_Scheduling.staff_id in (select hr_staff.staff_id from hr_staff where " + delschWhere + ")";
                wher = string.Format(wher, HR_Scheduling.Attribute.SchYear, HR_Scheduling.Attribute.SchMonth, HR_Scheduling.Attribute.SchDay,
                                sDate.Year, sDate.Month, sDate.Day,
                                HR_Scheduling.Attribute.SchYear, HR_Scheduling.Attribute.SchMonth, HR_Scheduling.Attribute.SchDay,
                                eDate.Year, eDate.Month, eDate.Day);
                int delCount = BLLTable.ExecSQL(new HR_Scheduling(), wher, CommandType.Text);
                while (delCount > 0)
                {
                    delsCount += delCount;
                    delCount = BLLTable.ExecSQL(new HR_Scheduling(), wher, CommandType.Text);
                    continue;
                }
                DataTable dataTable = BLLTable<HR_Scheduling>.qDataTable("select * from " + HR_Scheduling.Attribute.SchDay.TableName + " where 1=2");
                List<DataRow> dataList = new List<DataRow>();
                foreach (HR_Scheduling sch in schList)
                {
                    DataRow dr = dataTable.NewRow();
                    foreach (DataColumn dc in dataTable.Columns)
                    {
                        dr[dc] = sch.GetValue(new AttributeItem(HR_Scheduling.Attribute.STAFF_ID.TableName, dc.ColumnName));
                    }
                    dataList.Add(dr);
                }

                try
                {
                    //将电量数据批量插入数据库
                    SqlBulkCopy sbc = new SqlBulkCopy(MyConfigurationSettings.GetValue("conn"));
                    sbc.BatchSize = 1000;
                    sbc.BulkCopyTimeout = (((dataList.Count) / 1000) + 1) * 3;
                    sbc.DestinationTableName = HR_Scheduling.Attribute.STAFF_ID.TableName;
                    sbc.WriteToServer(dataList.ToArray());
                    buildCount += dataList.Count;
                }
                catch { }
            }
            else
            {
                foreach (HR_Scheduling sch in schList)
                {
                    if (!BLLTable<HR_Scheduling>.Exists(sch))
                        buildCount += BLLTable<HR_Scheduling>.Factory(conn).Insert(sch, HR_Scheduling.Attribute.ID);
                }
            }
            int ret2 = BLLTable<HR_Scheduling_IniProject>.Factory(conn).Insert(proj, HR_Scheduling_IniProject.Attribute.ID);
            litScript.Text = "<script>alert('生成成功!" + (chkFuGai.Checked ? "覆盖" : "增补") + "生成" + buildCount + "条记录!删除" + delsCount
                + "条记录,保存" + ret2 + "个配置方案"
                + "');$('.main').unmask();</script>";
        }
        else
        {
            wran = "休息日输入有误!请参考提示输入。";
        }

        if (!string.IsNullOrEmpty(wran))
        {
            litWarn.Text = wran;
            litWarn.Visible = true;
            litScript.Text = "<script>alert('" + wran + "');$('.main').unmask();</script>";
        }
    }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        try
        {
            HR_STAFF stfVal = new HR_STAFF();
            stfVal.STAFF_ID = 0;
            List<HR_STAFF> stffs = BLLTable<HR_STAFF>.Factory(conn).Select(stfVal, new HR_STAFF());
            string[] schidstr = hidSelBanciId.Value.TrimEnd(',').Split(',');
            List<int> schids = new List<int>();
            for (int i = 0; i < schidstr.Length; i++)
            {
                int sid = -1;
                if (int.TryParse(schidstr[i], out sid))
                    schids.Add(sid);
            }
            int stfCount = 0;
            int stfSch = 0;
            DateTime sDate = DateTime.Parse(txtStartTime.Value);
            DateTime eDate = DateTime.Parse(txtEndTime.Value);
            DateTime dt = sDate;
            List<HR_Scheduling> schList = new List<HR_Scheduling>();
            foreach (HR_STAFF stf in stffs)
            {
                stfCount++;
                dt = sDate;
                while (dt.Date <= eDate.Date)
                {
                    foreach (int schid in schids)
                    {
                        HR_Scheduling sch = new HR_Scheduling();
                        sch._SchYear = dt.Date.Year;
                        sch._SchMonth = Convert.ToInt16(dt.Date.Month);
                        sch._SchDay = Convert.ToInt16(dt.Date.Day);
                        sch._STAFF_ID = Convert.ToInt32(stf.STAFF_ID);
                        sch._SchType = Convert.ToInt32(txtType.Value);
                        sch._SchClassid = schid;
                        schList.Add(sch);
                    }
                    dt = dt.AddDays(1);
                    stfSch++;
                }
            }
            int buildCount = 0;
            HR_Scheduling delCon = new HR_Scheduling();
            delCon.Top(500);
            string wher = " CAST(CAST({0} AS char(4)) + '-' + CAST({1} AS char(2)) + '-' + CAST({2} AS char(2)) as datetime) >= '{3}-{4}-{5}' and CAST(CAST({6} AS char(4)) + '-' + CAST({7} AS char(2)) + '-' + CAST({8} AS char(2)) as datetime) <= '{9}-{10}-{11}' ";
            delCon.Where(wher, HR_Scheduling.Attribute.SchYear, HR_Scheduling.Attribute.SchMonth, HR_Scheduling.Attribute.SchDay,
                            sDate.Year, sDate.Month, sDate.Day,
                            HR_Scheduling.Attribute.SchYear, HR_Scheduling.Attribute.SchMonth, HR_Scheduling.Attribute.SchDay,
                            eDate.Year, eDate.Month, eDate.Day);
            while (BLLTable<HR_Scheduling>.Factory(conn).Delete(delCon) > 0)
            {
                continue;
            }
            DataTable dataTable = BLLTable<HR_Scheduling>.qDataTable("select * from " + HR_Scheduling.Attribute.SchDay.TableName + " where 1=2");
            List<DataRow> dataList = new List<DataRow>();
            foreach (HR_Scheduling sch in schList)
            {
                DataRow dr = dataTable.NewRow();
                foreach (DataColumn dc in dataTable.Columns)
                {
                    dr[dc] = sch.GetValue(new AttributeItem(HR_Scheduling.Attribute.STAFF_ID.TableName, dc.ColumnName));
                }
                dataList.Add(dr);
            }

            try
            {
                //���������������������ݿ�
                SqlBulkCopy sbc = new SqlBulkCopy(MyConfigurationSettings.GetValue("conn"));
                sbc.BatchSize = 1000;
                sbc.BulkCopyTimeout = (((dataList.Count) / 1000) + 1) * 3;
                sbc.DestinationTableName = HR_Scheduling.Attribute.STAFF_ID.TableName;
                sbc.WriteToServer(dataList.ToArray());
                buildCount += dataList.Count;
            }
            catch { }
            ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "$('.main').unmask();alert('�ɹ��޸�" + buildCount + "����¼');", true);
        }
        catch (Exception ex)
        {
            litWarn.Text = ex.Message;
        }
    }
    private void BindList(HR_Scheduling condObj, int curPage)
    {
        if (condObj.af_PageByAttributeItem == null)//����������û�����ķ�ҳ�������ԣ�����������������
            condObj.af_PageBy(HR_Scheduling.Attribute.SchDay, Order.Desc);

        #region//����Ȩ������

        #endregion
        //condObj.PID = decimal.Parse(pid);

        listObj = BLLTable<HR_Scheduling>.Factory(conn).SelectByPage(valObj, condObj, aspPager.PageSize, curPage, ref recount);
        repList.DataSource = listObj;
        repList.DataBind();
        aspPager.RecordCount = recount;
    }