Exemplo n.º 1
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     if (txtPasswd.Text == txtPwdCheck.Text)
     {
         bool            isOk     = false;
         MySqlParameters mySql    = new MySqlParameters("s_user");
         DataFrom        dataFrom = new DataFrom();
         try
         {
             mySql.EditSqlMode = SqlMode.Update;
             mySql.Add("pwd", txtPasswd.Text);
             mySql.Add("id", CurrentUser.Id, "and id={0}");
             mySql.Add("oldpwd", txtPwdOld.Text, "and pwd={0}");
             isOk = dataFrom.SqlExecute(mySql) == 1;
         }
         catch (Exception ex)
         {
             Logger.Error(SqlHelper.GetSql(mySql, dataFrom.Dbtype), ex);
         }
         if (isOk)
         {
             Alert("密码修改成功!下次请使用新密码");
         }
         else
         {
             Alert("原密码输入错误,请重输!");
         }
     }
     else
     {
         Alert("两次密码输入不一致,请重输!");
     }
 }
Exemplo n.º 2
0
        protected void btnBuild_Click(object sender, EventArgs e)
        {
            DateTime startDate = DataHelper.GetDateValue(StartDate.Text, DateTime.Today);
            DateTime endDate   = DataHelper.GetDateValue(EndDate.Text, DateTime.Today);

            if (startDate > endDate)
            {
                Alert("您要生成的日期的开始日期不能大于截止日期", EndDate.ClientID);
                return;
            }
            int weekStart = DataHelper.GetIntValue(WebHelper.GetAppConfig("WeekStart"), 0);
            int weekcount = DataHelper.GetWeekOfYear(startDate);

            //如果开始日期不是周开始日期向前修正为周开始日期
            startDate = DataHelper.GetWeekStart(startDate, weekStart);
            //如果总星期计数存在,则取最大值加1,否则将其置为1
            int    weekid    = DataHelper.GetIntValue(deal.GetScalar("select max(weekid)+1 from workweek"), 1);
            string insertSql = "insert workweek (weekid, workday, iflag, weeksn) values ({0}, '{1}', {2}, {3})";

            while (startDate <= endDate)
            {
                //周跨年度是作为下一年的 第一周
                if (startDate.AddDays(7).Year > startDate.Year)
                {
                    weekcount = 1;
                }
                for (int j = 0; j < 7; j++)
                {
                    if (startDate.DayOfWeek == DayOfWeek.Saturday || startDate.DayOfWeek == DayOfWeek.Sunday)
                    {
                        deal.SqlExecute(String.Format(insertSql, weekid, startDate, 0, weekcount));
                    }
                    else
                    {
                        deal.SqlExecute(String.Format(insertSql, weekid, startDate, 1, weekcount));
                    }
                    startDate = startDate.AddDays(1);
                }
                weekcount++;
                weekid++;
            }
            Response.Redirect(Request.Url.AbsoluteUri);
        }
Exemplo n.º 3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(Content.Text) || Content.Text.Length < 10)
            {
                Alert("内容不能为空并且必须10个字以上!");
                return;
            }
            XmlDocument doc = null;

            if (txtXml.Text.Length > 0)
            {
                string msg = null;
                doc = new XmlDocument();
                try
                {
                    doc.LoadXml(txtXml.Text);
                    if (!XmlHelper.HasChildNode(doc.DocumentElement, "myquery") ||
                        !XmlHelper.HasChildNode(doc.DocumentElement, "myquery/sql"))
                    {
                        msg = "XML配置文件不符合系统规范";
                    }
                }
                catch (Exception ex)
                {
                    msg = "xml语法错误:" + ex.Message;
                }
                if (!String.IsNullOrEmpty(msg))
                {
                    Alert(msg);
                    return;
                }
            }
            bool            isOk  = false;
            MySqlParameters mySql = new MySqlParameters("HtmlTemplate");

            if (String.IsNullOrEmpty(name))
            {
                mySql.EditSqlMode = SqlMode.Insert;
            }
            else
            {
                mySql.EditSqlMode = SqlMode.Update;
                mySql.Add("whereHtmlUrl", name, "HtmlUrl={0}");
            }
            string htmlUrl = HtmlUrl.Text;

            if (!htmlUrl.EndsWith(DepId.SelectedValue))
            {
                htmlUrl += DepId.SelectedValue;
            }
            mySql.Add("HtmlUrl", htmlUrl);
            string aspxUrl = AspxUrl.Text;

            if (String.IsNullOrEmpty(aspxUrl))
            {
                aspxUrl = HtmlGenerate.GetAspxUrl(htmlUrl);
            }
            mySql.Add("AspxUrl", aspxUrl);
            mySql.Add("Title", txtTitle.Text);
            mySql.Add("depid", DepId.SelectedValue);
            mySql.Add("optime", DateTime.Now);
            mySql.Add("userid", CurrentUser.Id);
            DataFrom data = new DataFrom();

            try
            {
                data.SqlExecute(mySql);
                TxtHelper.WriteToFile(WebHelper.GetMyXmlPath() + "\\tpl\\" + name + Constants.HTML_SUFFIX, Content.Text, true);
                if (doc != null)
                {
                    doc.Save(WebHelper.GetMyXmlPath() + "\\query\\" + name + Constants.XML_SUFFIX);
                }
                isOk = true;
            }
            catch (Exception ex)
            {
                Logger.Error(SqlHelper.GetSql(mySql, data.Dbtype), ex);
                RedirectError("提交失败,请稍候再试。原因:" + ex.Message);
                return;
            }
            if (isOk)
            {
                Redirect("Tmp/MyQuery.aspx?" + Constants.MYQUERY_NAME + "=listHtmlTemplate&sy=1");
            }
        }
Exemplo n.º 4
0
 protected void btnUp_Click(object sender, EventArgs e)
 {
     if (fileHtml.Value.Length > 0)
     {
         int    p        = fileHtml.Value.IndexOf("\\web\\", StringComparison.CurrentCultureIgnoreCase);
         string fileName = Path.GetFileName(fileHtml.PostedFile.FileName);
         if (p == -1)
         {
             if (fileName.EndsWith(Constants.HTML_SUFFIX, StringComparison.CurrentCultureIgnoreCase))
             {
                 //上传htm模板
                 string rootPath = WebHelper.GetMyXmlPath() + "\\tpl\\";
                 try
                 {
                     fileHtml.PostedFile.SaveAs(rootPath + fileName);
                     DataFrom        data  = new DataFrom();
                     MySqlParameters mySql = HtmlGenerate.GetHtmlTemplate(data, fileName, CurrentUser.Id);
                     if (mySql != null)
                     {
                         data.SqlExecute(mySql);
                     }
                     name = fileName.ToLower().Replace(Constants.HTML_SUFFIX, "");
                 }
                 catch (Exception ex)
                 {
                     Logger.Error("上传HTML模板错误", ex);
                     RedirectError("上传HTML模板失败,请稍后重试。原因:" + ex.Message);
                     return;
                 }
             }
             else if (fileName.EndsWith(Constants.XML_SUFFIX, StringComparison.CurrentCultureIgnoreCase))
             {
                 string rootPath = WebHelper.GetMyXmlPath() + "\\query\\";
                 try
                 {
                     fileHtml.PostedFile.SaveAs(rootPath + fileName);
                 }
                 catch (Exception ex)
                 {
                     Logger.Error("上传XML配置错误", ex);
                     RedirectError("上传XML配置失败,请稍后重试。原因:" + ex.Message);
                     return;
                 }
             }
             else
             {
                 Alert("请选择HTML模板");
                 return;
             }
         }
         else
         {
             //上传web 目录文件
             try
             {
                 string rootPath = WebHelper.GetRootServerPath() + fileHtml.Value.Substring(p + 5, fileHtml.Value.LastIndexOf("\\") - p - 4);
                 fileHtml.PostedFile.SaveAs(rootPath + fileName);
             }
             catch (Exception ex)
             {
                 Logger.Error("上传覆盖错误", ex);
                 RedirectError("上传覆盖失败,请稍后重试。原因:" + ex.Message);
                 return;
             }
         }
     }
     else
     {
         Alert("请选择HTML模板");
     }
     if (fileXml.Value.Length > 0 &&
         fileXml.PostedFile.FileName.EndsWith(Constants.XML_SUFFIX, StringComparison.CurrentCultureIgnoreCase) &&
         !String.IsNullOrEmpty(name))
     {
         string rootPath = WebHelper.GetMyXmlPath() + "\\query\\";
         try
         {
             fileXml.PostedFile.SaveAs(rootPath + name + Constants.XML_SUFFIX);
         }
         catch (Exception ex)
         {
             Logger.Error("上传XML配置错误", ex);
             RedirectError("上传XML配置失败,请稍后重试。原因:" + ex.Message);
             return;
         }
     }
     if (!String.IsNullOrEmpty(name))
     {
         Redirect("Tmp/EditHtml.aspx?" + Constants.MYQUERY_NAME + "=" + name + "&sy=1");
     }
 }