Ejemplo n.º 1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            User_BAL          objUserImpl = new User_BAL();
            UserExtension_DTO objInfo     = objUserImpl.Login(txtUsername.Text, StringHelper.MD5(txtPassword.Text));

            if (objInfo != null)
            {
                if (objInfo.IsLock == true)
                {
                    litError.Text = "<div class='alert alert-danger'><button class='close' data-close='alert'></button><span>Tài khoản đang bị khóa!</span></div>";
                }
                else
                {
                    Session["LockScreen"] = false;
                    Session["UserLogin"]  = objInfo;
                    if (chkRemember.Checked == true)
                    {
                        HttpCookie userCookie = new HttpCookie("userInfo");
                        userCookie.Values["userName"] = txtUsername.Text;
                        userCookie.Values["password"] = txtPassword.Text;
                        userCookie.Expires            = DateTime.Now.AddDays(1);
                        Response.Cookies.Add(userCookie);
                    }
                    objUserImpl.UpdateLastIPAddress(objInfo.UserID, GetIPAddress());
                    Response.Redirect("~/Default");
                }
            }
            else
            {
                litError.Text = "<div class='alert alert-danger'><button class='close' data-close='alert'></button><span>Tài khoản và mật khẩu không đúng!</span></div>";
            }
        }
Ejemplo n.º 2
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (Session["UserLogin"] != null)
     {
         UserExtension_DTO objInfo = (UserExtension_DTO)Session["UserLogin"];
         User_BAL          objImpl = new User_BAL();
         if (objInfo.Password == StringHelper.MD5(txtCurrentPassword.Text))
         {
             objImpl.ChangePassword(objInfo.UserID, StringHelper.MD5(txtNewPassword.Text));
             litError.Text = "<div class='alert alert-danger'><button class='close' data-close='alert'></button><span>Thay đổi mật khẩu thành công!</span></div>";
         }
         else
         {
             litError.Text = "<div class='alert alert-danger'><button class='close' data-close='alert'></button><span>Mật khẩu không đúng!</span></div>";
         }
     }
 }
Ejemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Session["LockScreen"] = true;
     if (Session["UserLogin"] != null)
     {
         UserExtension_DTO objInfo = (UserExtension_DTO)Session["UserLogin"];
         lblFullName.Text  = objInfo.FullName;
         lblFullName1.Text = objInfo.FullName;
         if (objInfo.ImagePath == "")
         {
             imgAvatar.ImageUrl = "/assets/img/avatar.jpg";
         }
         else
         {
             imgAvatar.ImageUrl = "/assets/global/employee/" + objInfo.ImagePath;
         }
     }
     else
     {
         Response.Redirect("~/Account/Login");
     }
 }
Ejemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["UserLogin"] != null)
         {
             UserExtension_DTO objInfo = (UserExtension_DTO)Session["UserLogin"];
             lblFullName.Text       = objInfo.FullName;
             lblDateOfBirth.Text    = objInfo.DateOfBirth.ToString("dd/MM/yyyy");
             lblGender.Text         = objInfo.Gender == true ? "Nam" : "Nữ";
             lblSubject.Text        = objInfo.SubjectName;
             lblPosition.Text       = objInfo.PositionName;
             txtAcademicRank.Text   = objInfo.AcademicRank;
             txtBachelorDegree.Text = objInfo.BachelorDegree;
             txtEmail.Text          = objInfo.Email;
             txtPhone.Text          = objInfo.Phone;
             txtAddress.Text        = objInfo.Address;
             hddImagePath.Value     = "/assets/global/employee/" + objInfo.ImagePath;
             hddFileImage.Value     = objInfo.ImagePath;
         }
     }
 }
Ejemplo n.º 5
0
 protected void btnLogin_Click(object sender, EventArgs e)
 {
     if (Session["UserLogin"] != null)
     {
         UserExtension_DTO objInfo     = (UserExtension_DTO)Session["UserLogin"];
         User_BAL          objUserImpl = new User_BAL();
         UserExtension_DTO objInfonew  = objUserImpl.Login(objInfo.UserName, StringHelper.MD5(txtPassword.Text));
         if (objInfonew != null)
         {
             Session["UserLogin"]  = objInfonew;
             Session["LockScreen"] = false;
             Response.Redirect("~/Default");
         }
         else
         {
             litError.Text = "<div class='alert alert-danger alert-lock'><button class='close' data-close='alert'></button><span>Mật khẩu không đúng!</span></div>";
         }
     }
     else
     {
         Response.Redirect("~/Account/Login");
     }
 }
Ejemplo n.º 6
0
        protected void btnSave_G_Click(object sender, EventArgs e)

        {
            GeneralEvent_DTO objInfo = new GeneralEvent_DTO();

            if (String.IsNullOrEmpty(ddlDepartment_G.SelectedValue))
            {
                objInfo.DepartmentID = -1;
            }
            else
            {
                objInfo.DepartmentID = int.Parse(ddlDepartment_G.SelectedValue);
            }
            if (String.IsNullOrEmpty(ddlSubject_G.SelectedValue))
            {
                objInfo.SubjectID = -1;
            }
            else
            {
                objInfo.SubjectID = int.Parse(ddlSubject_G.SelectedValue);
            }
            objInfo.Title = txtTitle_G.Text;
            DateTime startDate = DateTime.ParseExact(txtStartDate_G.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);

            objInfo.StartDate = startDate;
            objInfo.EndDate   = startDate;
            if (String.IsNullOrEmpty(txtTimeStart_G.Text) == false)
            {
                Char     delimiter = ':';
                String[] str       = txtTimeStart_G.Text.Split(delimiter);
                objInfo.StartDate = objInfo.StartDate.AddHours(Double.Parse(str[0]));
                objInfo.StartDate = objInfo.StartDate.AddMinutes(Double.Parse(str[1]));
            }
            if (String.IsNullOrEmpty(txtTimeEnd_G.Text) == false)
            {
                Char     delimiter = ':';
                String[] str       = txtTimeEnd_G.Text.Split(delimiter);
                objInfo.EndDate = objInfo.EndDate.AddHours(Double.Parse(str[0]));
                objInfo.EndDate = objInfo.EndDate.AddMinutes(Double.Parse(str[1]));
            }
            objInfo.Description = txtDescription_G.Text;
            objInfo.Location    = txtLocation_G.Text;
            objInfo.Organizer   = txtOrganizer_G.Text;
            objInfo.Participant = txtParticipant_G.Text;
            objInfo.Preparation = txtPreparation_G.Text;
            objInfo.IsDone      = chkIsDone_G.Checked;
            objInfo.IsImportant = chkIsImportant_G.Checked;
            UserExtension_DTO objUsserInfo = (UserExtension_DTO)Session["UserLogin"];

            objInfo.ModifyBy  = objUsserInfo.UserName;
            objInfo.CreatedBy = objUsserInfo.UserName;
            GeneralEvent_BAL objImpl = new GeneralEvent_BAL();
            var data_path            = "/assets/global/event/";

            if (GeneralEventID > 0)
            {
            }
            else
            {
                if (rdoRecurrenceNone_G.Checked)
                {
                    GeneralEventID = objImpl.Insert(objInfo);
                    if (fileAttachments.PostedFile != null && fileAttachments.FileName.Length > 0)
                    {
                        if (!Directory.Exists(Server.MapPath(data_path)))
                        {
                            Directory.CreateDirectory(Server.MapPath(data_path));
                        }
                        EventFile_BAL objEventFile_BAL = new EventFile_BAL();
                        foreach (HttpPostedFile postedFile in fileAttachments.PostedFiles)
                        {
                            string fileNameImage = Guid.NewGuid().ToString() + Path.GetExtension(postedFile.FileName.ToLower());
                            postedFile.SaveAs(Server.MapPath(data_path + fileNameImage));
                            EventFile_DTO objEventFile_DTO = new EventFile_DTO();
                            objEventFile_DTO.GeneralEventID = GeneralEventID;
                            objEventFile_DTO.FileName       = postedFile.FileName.ToLower();
                            objEventFile_DTO.FilePath       = fileNameImage;
                            objEventFile_DTO.FileSize       = postedFile.ContentLength;
                            objEventFile_BAL.Insert(objEventFile_DTO);
                        }
                    }
                }
                if (rdoRecurrencePeriodic_G.Checked)
                {
                    int      PeriodicAmount      = int.Parse(txtPeriodicAmount_G.Text);
                    string   PeriodicCode        = ddlPeriodicCode_G.SelectedValue;
                    DateTime RecurrenceStartDate = DateTime.ParseExact(txtRecurrenceStartDate_G.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    DateTime RecurrenceEndDate   = DateTime.ParseExact(txtRecurrenceEndDate_G.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    int      OriginalEventID     = -1;
                    while (DayDifference(RecurrenceStartDate, RecurrenceEndDate) < 0)
                    {
                        objInfo.OriginalEventID = OriginalEventID;
                        objInfo.StartDate       = RecurrenceStartDate;
                        objInfo.EndDate         = RecurrenceStartDate;
                        if (String.IsNullOrEmpty(txtTimeStart_G.Text) == false)
                        {
                            Char     delimiter = ':';
                            String[] str       = txtTimeStart_G.Text.Split(delimiter);
                            objInfo.StartDate = objInfo.StartDate.AddHours(Double.Parse(str[0]));
                            objInfo.StartDate = objInfo.StartDate.AddMinutes(Double.Parse(str[1]));
                        }
                        if (String.IsNullOrEmpty(txtTimeEnd_G.Text) == false)
                        {
                            Char     delimiter = ':';
                            String[] str       = txtTimeEnd_G.Text.Split(delimiter);
                            objInfo.EndDate = objInfo.EndDate.AddHours(Double.Parse(str[0]));
                            objInfo.EndDate = objInfo.EndDate.AddMinutes(Double.Parse(str[1]));
                        }
                        int id = objImpl.Insert(objInfo);
                        if (OriginalEventID == -1)
                        {
                            OriginalEventID = id;
                        }
                        switch (PeriodicCode)
                        {
                        case "d":
                            RecurrenceStartDate = RecurrenceStartDate.AddDays(PeriodicAmount);
                            break;

                        case "w":
                            RecurrenceStartDate = RecurrenceStartDate.AddDays(PeriodicAmount * 7);
                            break;

                        case "m":
                            RecurrenceStartDate = RecurrenceStartDate.AddMonths(PeriodicAmount);
                            break;

                        case "y":
                            RecurrenceStartDate = RecurrenceStartDate.AddYears(PeriodicAmount);
                            break;

                        default:
                            RecurrenceStartDate = RecurrenceEndDate;
                            break;
                        }
                    }
                }
                if (rdoRecurrenceMonthlyActual_G.Checked)
                {
                    int      ActualMonthlyDay    = int.Parse(ddlActualMonthlyDay_G.SelectedValue);
                    DateTime RecurrenceStartDate = DateTime.ParseExact(txtRecurrenceStartDate_G.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    DateTime RecurrenceEndDate   = DateTime.ParseExact(txtRecurrenceEndDate_G.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    int      day = ActualMonthlyDay - RecurrenceStartDate.Day;
                    RecurrenceStartDate = RecurrenceStartDate.AddDays(day);
                    int OriginalEventID = -1;
                    while (DayDifference(RecurrenceStartDate, RecurrenceEndDate) < 0)
                    {
                        objInfo.OriginalEventID = OriginalEventID;
                        objInfo.StartDate       = RecurrenceStartDate;
                        objInfo.EndDate         = RecurrenceStartDate;
                        if (String.IsNullOrEmpty(txtTimeStart_G.Text) == false)
                        {
                            Char     delimiter = ':';
                            String[] str       = txtTimeStart_G.Text.Split(delimiter);
                            objInfo.StartDate = objInfo.StartDate.AddHours(Double.Parse(str[0]));
                            objInfo.StartDate = objInfo.StartDate.AddMinutes(Double.Parse(str[1]));
                        }
                        if (String.IsNullOrEmpty(txtTimeEnd_G.Text) == false)
                        {
                            Char     delimiter = ':';
                            String[] str       = txtTimeEnd_G.Text.Split(delimiter);
                            objInfo.EndDate = objInfo.EndDate.AddHours(Double.Parse(str[0]));
                            objInfo.EndDate = objInfo.EndDate.AddMinutes(Double.Parse(str[1]));
                        }
                        RecurrenceStartDate = RecurrenceStartDate.AddMonths(1);
                        int id = objImpl.Insert(objInfo);
                        if (OriginalEventID == -1)
                        {
                            OriginalEventID = id;
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            UserExtension_DTO objUserExtensInfo = new UserExtension_DTO();;

            if (Session["UserLogin"] != null)
            {
                objUserExtensInfo = (UserExtension_DTO)Session["UserLogin"];
            }
            Employee_DTO objInfo = new Employee_DTO();

            objInfo.FullName       = objUserExtensInfo.FullName;
            objInfo.DateOfBirth    = DateTime.ParseExact(lblDateOfBirth.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            objInfo.Gender         = objUserExtensInfo.Gender;
            objInfo.SubjectID      = objUserExtensInfo.SubjectID;
            objInfo.PositionID     = objUserExtensInfo.PositionID;
            objInfo.AcademicRank   = txtAcademicRank.Text;
            objInfo.BachelorDegree = txtBachelorDegree.Text;
            objInfo.Email          = txtEmail.Text;
            objInfo.Address        = txtAddress.Text;
            objInfo.Phone          = txtPhone.Text;
            objInfo.EmployeeID     = objUserExtensInfo.UserID;
            Employee_BAL objImpl   = new Employee_BAL();
            var          data_path = "/assets/global/employee/";

            if (fuImagePath.PostedFile != null && fuImagePath.FileName.Length > 0)
            {
                if (!Directory.Exists(Server.MapPath(data_path)))
                {
                    Directory.CreateDirectory(Server.MapPath(data_path));
                }
                string fileNameImage = Guid.NewGuid().ToString() + Path.GetExtension(fuImagePath.PostedFile.FileName.ToLower());
                this.fuImagePath.PostedFile.SaveAs(Server.MapPath(data_path + fileNameImage));
                objInfo.ImagePath = fileNameImage;
                if (!string.IsNullOrEmpty(this.hddFileImage.Value))
                {
                    string PathFile = Server.MapPath(data_path + hddFileImage.Value);
                    if (File.Exists(PathFile))
                    {
                        File.Delete(PathFile);
                    }
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(this.hddFileImage.Value))
                {
                    if (this.hddRemoveImage.Value == "1")
                    {
                        string PathFile = Server.MapPath(data_path + this.hddFileImage.Value);
                        if (File.Exists(PathFile))
                        {
                            File.Delete(PathFile);
                        }
                        objInfo.ImagePath = "";
                    }
                    else
                    {
                        objInfo.ImagePath = hddFileImage.Value;
                    }
                }
            }
            objImpl.Update(objInfo);
            Session["UserLogin"] = (new User_BAL()).Login(objUserExtensInfo.UserName, objUserExtensInfo.Password);
            litError.Text        = "<div class='alert alert-danger'><button class='close' data-close='alert'></button><span>Cập nhật thông tin cá nhân thành công!</span></div>";
        }