Example #1
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>";
        }
    }
Example #2
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        //try
        //{
        SYS_BILL_COL_SYN valObj = new SYS_BILL_COL_SYN();

        if (txtBILL_ID.Value != "")
        {
            valObj.BILL_ID = Convert.ToInt32(txtBILL_ID.Value);
        }

        //if (keyid == "")
        //{
        //    if (BLLTable<SYS_BILL_COL_SYN>.Exists(valObj))
        //    {
        //        litWarn.Text = "ÒѾ­´æÔÚ´Ë×ֶΣ¡";
        //        return;
        //    }
        //}

        #region
        if (txtTABLE_NAME.Value != "")
        {
            valObj.TABLE_NAME = Convert.ToString(txtTABLE_NAME.Value);
        }
        else
        {
            if (txtTABLE_NAME1.Value != "")
            {
                valObj.TABLE_NAME = Convert.ToString(txtTABLE_NAME1.Value);
            }
        }

        DataBaseField field = null;
        if (txtCOL_NAME.Value != "")
        {
            valObj.COL_NAME = Convert.ToString(txtCOL_NAME.Value);
            try
            {
                field = DataBase.Factory(MyConfigurationSettings.GetValue(txtDB_SRC.Value)).DataTables[valObj.TABLE_NAME].DataFields[valObj.COL_NAME];
            }
            catch { field = null; }
        }
        if (field == null)
        {
            litWarn.Text = "±£´æʧ°Ü£¡Ã»ÓÐÕÒµ½¸Ã×ֶΣ¡";
            return;
        }

        if (txtCOL_ID.Value != "")
        {
            valObj.COL_ID = Convert.ToInt32(txtCOL_ID.Value);
        }

        valObj.ISPK = field.IsKeyID ? "1" : "0";

        valObj.COL_NOTE = field.Desc.ZhName;

        valObj.DATA_TYPE = field.DataType.TypeNameString;

        valObj.DATA_LEN = field.DataType.DataLen;

        valObj.DATA_ACC = field.DataType.Scale;

        valObj.IS_AUTO = field.IsAutoIncrease ? "1" : "0";

        valObj.DVAL = field.DefaultValue;

        valObj.DB_SRC = txtDB_SRC.Value;

        valObj.PK_VALCODE = txtPK_VALCODE.Value;
        #endregion

        if (keyid != "")
        {
            valObj.COL_SYNID = Convert.ToInt32(keyid);

            count = BLLTable <SYS_BILL_COL_SYN> .Factory(conn).Update(valObj, SYS_BILL_COL_SYN.Attribute.COL_SYNID);
        }
        else
        {
            valObj.SetInitialized(SYS_BILL_COL_SYN.Attribute.COL_SYNID, false);
            count = BLLTable <SYS_BILL_COL_SYN> .InsertReturnID(valObj);

            keyid = count.ToString();
            ViewState["KEYID"] = keyid;
            if (count > 0 && valObj.ISPK == "1")
            {
                SYS_BILL_COL_EXD billExd = new SYS_BILL_COL_EXD(valObj.ToBILL_COL());
                billExd.Add();
            }
        }
        if (count > 0)
        {
            if (Request["tree"] != null)
            {
                StringBuilder sb = new StringBuilder("{");
                sb.Append("id:'");
                sb.Append(keyid).Append("',pid:'").Append(valObj.COL_ID).Append("',no:1,sc:0,name:'");

                sb.Append(valObj.COL_NAME + "[" + valObj.COL_NOTE + "]").Append("',ntype:'syncol'}");

                if (Request["edit"] == null)
                {
                    AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.showSubNodes(\"" + sb.ToString() + "\");", false);
                }
                else
                {
                    AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.editNodeInfo(\"" + sb.ToString() + "\");", false);
                }
                litWarn.Text = "±£´æ³É¹¦";
            }
            else
            {
                #region
                StringBuilder        sbData = new StringBuilder("{valObj:''");
                List <AttributeItem> lstCol = valObj.af_AttributeItemList;
                for (int i = 0; i < lstCol.Count; i++)
                {
                    object val = valObj.GetValue(lstCol[i]);
                    if (val != null)
                    {
                        sbData.Append(",").Append(lstCol[i].FieldName).Append(":'").Append(val.ToString()).Append("'");
                    }
                }
                sbData.Append("}");
                if (ViewState["sbData"] == null)
                {
                    ViewState["sbData"] = sbData.ToString();
                }
                else
                {
                    ViewState["sbData"] += "," + sbData.ToString();
                }
                Button btn = (Button)sender;
                if (btn.ID.IndexOf("btnOK") != -1)
                {
                    if (ViewState["sbData"] == null)
                    {
                        string dataStr = "[" + ViewState["sbData"].ToString() + "]";
                        ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "_FormView();if (window.opener){window.opener.returnValue = '" + dataStr + "';}else{window.returnValue = '" + dataStr + "';}window.close();", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "_FormView();if (window.opener){window.opener.returnValue = 're';}else{window.returnValue = 're';}window.close();", true);
                    }
                }
                else
                {
                    AgileFrame.Core.ScriptHelper.ResponseScript(Page, "_FormView();", false);
                    txtTABLE_NAME.Value = "";
                    txtCOL_NAME.Value   = "";
                    hidTABLE_NAME.Value = "";
                }
                #endregion
            }
        }
        else
        {
            litWarn.Text = "ÐÞ¸Äʧ°Ü£¡";
        }
        //}
        //catch (Exception ex)
        //{
        //    litWarn.Text = ex.Message;
        //}
    }
Example #3
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;
        }
    }
Example #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // EntityFactory.CheckEntityAndDB("WEC");
        if (Request["preUrl"] != null)
        {
            preUrl = Request["preUrl"];
        }
        //系统帐套
        if (MyConfigurationSettings.GetValue <string>("CloudSystem") == "1")
        {
            if (DataBase.Factory(BasePage.cloudConn).Exist("A8Account"))
            {
                A8Account        val   = new A8Account();
                List <A8Account> list1 = BLLTable <A8Account> .Factory(BasePage.cloudConn).Select(val);

                if (list1.Count > 0)
                {
                    HtmlSelect sel1 = new HtmlSelect();
                    sel1.Items.AddRange(FormHelper.GetListItem(A8Account.Attribute.ConnectStr, A8Account.Attribute.ConnectStr, A8Account.Attribute.FullName));
                    //sel1.InnerHtml;
                }
            }
        }
        //系统皮肤
        SYS_THEME theme = BLLTable <SYS_THEME> .Factory(conn).GetRowData(SYS_THEME.Attribute.THEME_NAME, _ThemeName);

        if (theme != null && !string.IsNullOrEmpty(theme.LOGIN_HTML))
        {
            Literal lll = new Literal();


            if (Request.Cookies["SYS_USER_USER_NAME"] != null)
            {
                name = Request.Cookies["SYS_USER_USER_NAME"].Value;
            }
            if (MyDebugger.IsAttached)//调试时加快速度
            {
                theme.LOGIN_HTML = theme.LOGIN_HTML.Replace("<%=name %>", "sys");
                theme.LOGIN_HTML = theme.LOGIN_HTML.Replace("name=\"password\"", "name=\"password\" value='123456'");
            }
            theme.LOGIN_HTML = theme.LOGIN_HTML.Replace("<%=name %>", name);

            //原模版有个脚本错误,屏蔽此问题
            //ie下密码为明文
            theme.LOGIN_HTML = theme.LOGIN_HTML.Replace("name=\"password\" type=\"text\"", "name=\"password\" type=\"password");

            lll.Text = theme.LOGIN_HTML;
            phLogin.Controls.Add(lll);

            string   appPath = WebHelper.GetAppPath();
            HtmlLink css     = new HtmlLink();
            css.Href = appPath + "Themes/" + _ThemeName + "/index.css";
            css.Attributes.Add("rel", "stylesheet");
            css.Attributes.Add("type", "text/css");

            this.Page.Header.Controls.Add(css);

            if (AgileFrame.Core.MyConfigurationSettings.GetValue("User_IsRunMode") == "Developer")
            {
                css      = new HtmlLink();
                css.Href = appPath + "Themes/" + _ThemeName + "/dev_index.css";
                css.Attributes.Add("rel", "stylesheet");
                css.Attributes.Add("type", "text/css");
                this.Page.Header.Controls.Add(css);
            }
        }
        else
        {
            phLogin.Controls.Add(TemplateControl.LoadControl("~/Themes/" + _ThemeName + "/Login.ascx"));
        }

        //string strIdentity = User.Identity.Name;
        //if (!string.IsNullOrEmpty(strIdentity))
        //{
        //    SYS_USER user = new SYS_USER();
        //    user = BLLTable<SYS_USER>.Factory(conn).GetRowData(SYS_USER.Attribute.USER_NAME, strIdentity);
        //    if (user != null)
        //    {
        //        bool tostaff = PowerHelper.SetCurLoginUser(user);
        //        if (tostaff == true)
        //        {
        //            Response.Redirect("Index.aspx");
        //        }
        //        else
        //        {
        //            AgileFrame.Core.ScriptHelper.Alert(Page, "您的用户未与员工信息关联,请联系管理员处理。");
        //        }
        //    }
        //}
        //if (MyDebugger.IsAttached)
        //{
        //    Response.Redirect("LoginBack.aspx?username=sys&password=123456");
        //}
    }