Example #1
0
        protected void Unnamed_ServerClick(object sender, EventArgs e)
        {
            UserBLL      User      = new UserBLL();
            AdminUserBLL adminUser = new AdminUserBLL();

            string    userName = user.Value;
            string    password = pwd.Value;
            DataTable dt       = User.selectid(userName, password);

            if (userName == "" && password == "")
            {
                JsHelper.Alert("账号或密码不能为空!");
                return;
            }
            Session["ID"] = dt.Rows[0]["id"];
            if (adminUser.UserLoginCheck(userName, password))
            {
                Session["UserName"] = userName;
                Response.Redirect("indexs.aspx");
            }
            else
            {
                JsHelper.Alert("账号或密码不正确!");
            }
        }
Example #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string action = Request["action"];
         if (action == "edit")
         {
             string id = Request["id"];
             //如果id为null或者空字符串就返回
             if (string.IsNullOrEmpty(id))
             {
                 return;
             }
             DataTable dt = news.FindNewById(id);
             if (dt.Rows.Count == 0)
             {
                 JsHelper.Alert("该新闻不存在!");
                 return;
             }
             tipe.Value    = dt.Rows[0]["tipe"].ToString();
             title.Value   = dt.Rows[0]["title"].ToString();
             content.Value = dt.Rows[0]["contents"].ToString();
         }
     }
 }
Example #3
0
        protected void lvNewList_ItemDeleting(object sender, ListViewDeleteEventArgs e)
        {
            NewBLL newsBll = new NewBLL();

            if (newsBll.RemoveNew(e.Keys["id"].ToString()) == 1)
            {
                lvNewList.EditIndex = -1;
                BindNewList();
                return;
            }
            JsHelper.Alert("删除失败");
        }
Example #4
0
        protected void Unnamed_ServerClick1(object sender, EventArgs e)
        {
            AdminUserBLL adminUser = new AdminUserBLL();
            string       userName  = user.Value;
            string       password  = pwd.Value;

            if (adminUser.UserLoginCheck(userName, password))
            {
                Session["UserName"] = userName;
                Response.Redirect("index.aspx");
            }
            else
            {
                JsHelper.Alert("账号或密码不正确!");
            }
        }
Example #5
0
        /// <summary>
        /// 更新新闻
        /// </summary>
        private void update()
        {
            NewModel newModel = new NewModel
            {
                id       = Request["id"],
                title    = title.Value,
                contents = content.Value,
                tipe     = tipe.Value
            };

            if (news.UpdateNew(newModel) == 1)
            {
                JsHelper.Alert("更新成功!");
            }
            else
            {
                JsHelper.Alert("更新失败!");
            }
        }
Example #6
0
        /// <summary>
        /// 发布新闻
        /// </summary>
        private void post()
        {
            NewModel newModel = new NewModel()
            {
                title    = title.Value,
                contents = content.Value,
                tipe     = tipe.Value
            };

            if (news.PostNew(newModel) == 1)
            {
                title.Value   = string.Empty;
                content.Value = string.Empty;
                JsHelper.Alert("发布成功!");
            }
            else
            {
                JsHelper.Alert("发布失败!");
            }
        }
Example #7
0
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lvNewList_ItemUpdating(object sender, ListViewUpdateEventArgs e)
        {
            NewModel newModel = new NewModel();

            newModel.id    = e.Keys["id"].ToString();
            newModel.title = e.NewValues["title"].ToString();
            //newModel.hit = e.NewValues["hit"].ToString();
            //newModel.tipe = e.NewValues["tipe"].ToString();
            newModel.time = e.NewValues["time"].ToString();

            NewBLL newsBll = new NewBLL();

            if (newsBll.UpdateNew(newModel) == 1)
            {
                lvNewList.EditIndex = -1;
                BindNewList();
                return;
            }
            JsHelper.Alert("更新失败");
        }
Example #8
0
 protected void btn1_ServerClick(object sender, EventArgs e)
 {
     try
     {
         string name     = uname.Value;
         string password = pass.Value;
         if (bll.CheckInfo(name, password))
         {
             Session["uname"] = name;
             Response.Redirect("Index.aspx");
         }
         else
         {
             JsHelper.Alert("账户或密码不正确,请重新输入");
         }
     }
     catch (Exception ex)
     {
         JsHelper.Alert(ex.Message);
     }
 }
Example #9
0
        public ActionResult Create(CreateEmployeeViewModel model)
        {
            try
            {
                // Get name
                string city         = _locationService.GetCity(System.Convert.ToInt64(model.CityId)).Name;
                string district     = _locationService.GetDistrict(System.Convert.ToInt64(model.DistrictId)).Name;
                string town         = _locationService.GetTown(System.Convert.ToInt64(model.TownId)).Name;
                long   departmentId = System.Convert.ToInt64(model.DepartmentId);

                // Get department
                var department = _departmentService.GetDepartmentById(departmentId);
                // string day = model.DayOfBirth;
                // Create new employee
                var employee = EntityFactory.CreateEmployee(model.FirstName, model.LastName,
                                                            model.IdCard, model.Email, model.PhoneNumber,
                                                            city, district, town, DateTimeHelper.CreateDate(model.DayOfBirth, model.MonthOfBirth, model.YearOfBirth),
                                                            DateTimeHelper.CreateDate(model.HireDay, model.HireMonth, model.HireYear),
                                                            model.Sex.ToString(), department);
                // Insert to DB
                bool insertResult = _employeeService.AddNewEmployee(employee);
                if (insertResult == true)
                {
                    // Return list employees
                    return(RedirectToAction("Index"));
                }
                else
                {
                    JsHelper.Alert("Khong hop le");
                    return(View());
                }
            }
            catch
            {
                return(View("Error"));
            }
        }
Example #10
0
        protected void Unnamed_ServerClick1(object sender, EventArgs e)
        {
            AdminUserBLL adminuserbll = new AdminUserBLL();
            UserBLL      userbll      = new UserBLL();
            string       Userpass     = pwd.Value;
            string       Username     = user.Value;

            if (Username == "" || Userpass == "")
            {
                Response.Write("<script language='javascript'> alert('不能为空');</script>");
                return;
            }
            if (userbll.CheckUser(Username) == 1)
            {
                JsHelper.Alert("管理员不能重复");
                user.Value = null;
                return;
            }
            int i = userbll.AddUserBLL(Username, Userpass);

            if (i == 1)
            {
                Response.Write("<script langeuage='javascript'>alert('添加成功');</script>");

                user.Value = null;
                pwd.Value  = null;
                return;
            }
            else
            {
                Response.Write("添加失败!");
                user.Value = "";
                pwd.Value  = "";
                return;
            }
        }
Example #11
0
    //上传
    protected void btnAddAttachment_Click(object sender, EventArgs e)
    {
        if (ddlCategory.SelectedIndex == 0)
        {
            JsHelper.Alert(Page, string.Format("请先选择“分类”再上传!"));
            ddlCategory.Focus();
            return;
        }

        if (FileUpload1.HasFile)
        {
            if (FileUpload1.FileName.Contains("#"))
            {
                JsHelper.Alert(Page, string.Format("文件名不能包含 # 特殊符号,请修改!"));
                return;
            }
            int fileUploadSize = 20;
            //fileUploadSize = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["FileUploadSize"]);
            if (FileUpload1.FileContent.Length / 1024.0 / 1024.0 > fileUploadSize)
            {
                JsHelper.Alert(Page, string.Format("附件大小不能超过{0}M", fileUploadSize));
                return;
            }
            string dir = ddlCategory.SelectedItem.Text;
            if (!Directory.Exists(Server.MapPath("~/WorkFlowRule/Upload/" + dir + "/")))
            {
                Directory.CreateDirectory(Server.MapPath("~/WorkFlowRule/Upload/" + dir + "/"));
            }
            string fileName = FileUpload1.FileName;
            string path     = "/WorkFlowRule/Upload/" + dir + "/" + fileName;

            List <AttachmentItem> items = (List <AttachmentItem>)ViewState["Attachments"];

            if (File.Exists(Server.MapPath("~" + path)))
            {
                AttachmentItem item  = items.Where(p => p.FilePath + p.FileName == path).FirstOrDefault();
                int            index = items.IndexOf(item);
                if (index > -1)
                {
                    items.RemoveAt(index);
                }
            }

            string fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
            FileUpload1.PostedFile.SaveAs(Server.MapPath(path));

            AttachmentItem model = new AttachmentItem();
            model.FileSize      = FileUpload1.PostedFile.ContentLength;
            model.FileName      = fileName;
            model.FilePath      = "/WorkFlowRule/Upload/" + dir + "/";
            model.Attachment_ID = Guid.NewGuid();
            model.Created_On    = DateTime.Now;

            items.Add(model);

            ViewState["Attachments"] = items;
            BindAttachment();
        }
        else
        {
            JsHelper.Alert(Page, "请选择文件!");
        }
    }