Example #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (lblstdid.Text.Length > 0)
            {
                try
                {
                    string serverpath = Server.MapPath(Request.ApplicationPath) + @"\file\" + PersonTools.CurrentPersianDateWithoutSlash() + PersonTools.CurrentTimeWithoutColons() + FileUpload1.FileName;
                    string filename   = PersonTools.CurrentPersianDateWithoutSlash() + PersonTools.CurrentTimeWithoutColons() + FileUpload1.FileName;

                    VStudentsRepository vstdir = new VStudentsRepository();

                    if (vstdir.FindByLinkUrl(filename) != null)
                    {
                        PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailedFileUploadrepeat, Color.Red);

                        return;
                    }
                    else
                    {
                        if (FileUpload1.FileName.Length > 0)
                        {
                            int filesize = FileUpload1.FileBytes.Length / 1024;
                            if (filesize >= 4000)
                            {
                                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailedFileUploadsize, Color.Red);
                                return;
                            }
                            else
                            {
                                FileUpload1.SaveAs(serverpath);
                            }
                        }
                        else
                        {
                            filename = Session["imageurl"].ToString();
                        }
                    }

                    if ((txtusername.Text.Length > 0) && (txtusername.Text != lblusername.Text))
                    {
                        if (vstdir.FindByuserName(txtusername.Text) != null)
                        {
                            PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errRepeatuserTitle, Color.Red);

                            return;
                        }
                    }
                    VStudentsRepository vstdirr = new VStudentsRepository();
                    Student             std     = new Student();
                    std.StudentID    = lblstdid.Text.ToInt();
                    std.StudentCode  = txtstdcode.Text;
                    std.FirstName    = txtname.Text;
                    std.LastName     = txtlastname.Text;
                    std.Gender       = RadioButtonList1.SelectedValue.ToInt();
                    std.NationalCode = txtnationalcode.Text;
                    std.FacultyID    = Session["newfacultyid"].ToString().ToInt();
                    std.LevelID      = Session["newlevelid"].ToString().ToInt();
                    std.FieldID      = Session["newfieldid"].ToString().ToInt();
                    std.TendencyID   = Session["newtenid"].ToString().ToInt();
                    std.EntryTerm    = RadioButtonList2.SelectedValue.ToInt();
                    if ((txtusername.Text.Length > 0) && (txtusername.Text != lblusername.Text))
                    {
                        std.Username = txtusername.Text;
                    }
                    else
                    {
                        std.Username = lblusername.Text;
                    }

                    if (txtpass.Text.Length > 0)
                    {
                        std.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5");
                    }
                    else
                    {
                        std.Password = Session["pass"].ToString();
                    }

                    std.Status        = (chkActiveAccount.Checked == true ? 0 : 1);
                    std.ImageFileName = filename;
                    vstdirr.Savestd(std);
                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgUpdateSuccessfull, Color.Green);
                }
                catch
                {
                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errUpdateFailed, Color.Red);
                }
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            VLecturersRepository vlec = new VLecturersRepository();

            if (vlec.FindByuserName(txtusername.Text) != null)
            {
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errDuplicateUsername, Color.Red);
                return;
            }



            bool successfullCreateAccount = true;

            try
            {
                string serverpath = Server.MapPath(Request.ApplicationPath) + @"\file\" + PersonTools.CurrentPersianDateWithoutSlash() + PersonTools.CurrentTimeWithoutColons() + FileUpload1.FileName;
                string filename   = PersonTools.CurrentPersianDateWithoutSlash() + PersonTools.CurrentTimeWithoutColons() + FileUpload1.FileName;

                VLecturersRepository vstdir = new VLecturersRepository();

                if (vstdir.FindByLinkUrl(filename) != null)
                {
                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailedFileUploadrepeat, Color.Red);

                    return;
                }
                else
                {
                    if (FileUpload1.FileName.Length > 0)
                    {
                        int filesize = FileUpload1.FileBytes.Length / 1024;
                        if (filesize >= 4000)
                        {
                            PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailedFileUploadsize, Color.Red);
                            return;
                        }
                        else
                        {
                            FileUpload1.SaveAs(serverpath);
                        }
                    }
                    else
                    {
                        //  PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailedFileUploadempty, Color.Red);
                        //  return;
                        filename = "";
                    }
                }



                Lecturer newstd = new Lecturer();

                newstd.FirstName    = txtname.Text;
                newstd.LastName     = txtlastname.Text;
                newstd.Gender       = RadioButtonList1.SelectedValue.ToInt();
                newstd.NationalCode = txtnationalcode.Text;
                newstd.FacultyID    = ddlfacultuy.SelectedValue.ToInt();

                newstd.FieldID    = ddlfield.SelectedValue.ToInt();
                newstd.TendencyID = ddltendency.SelectedValue.ToInt();

                newstd.Username = txtusername.Text;
                newstd.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5");

                newstd.ImageFileName = filename;
                newstd.Status        = (chkActiveAccount.Checked == true ? 0 : 1);


                VLecturersRepository vstdirr = new VLecturersRepository();
                vstdirr.Savestd(newstd);


                clearform();
            }
            catch (System.Exception err)
            {
                successfullCreateAccount = false;

                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailed, Color.Red);
            }
            if (successfullCreateAccount)
            {
                // ClearForm();
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgAddSuccessfull, Color.Green);
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (lblempid.Text.Length > 0)
            {
                try
                {
                    string serverpath = Server.MapPath(Request.ApplicationPath) + @"\file\" + PersonTools.CurrentPersianDateWithoutSlash() + PersonTools.CurrentTimeWithoutColons() + FileUpload1.FileName;
                    string filename   = PersonTools.CurrentPersianDateWithoutSlash() + PersonTools.CurrentTimeWithoutColons() + FileUpload1.FileName;


                    VEmployeesRepository vLecir = new VEmployeesRepository();
                    if (vLecir.FindByLinkUrl(filename) != null)
                    {
                        PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailedFileUploadrepeat, Color.Red);

                        return;
                    }
                    else
                    {
                        if (FileUpload1.FileName.Length > 0)
                        {
                            int filesize = FileUpload1.FileBytes.Length / 1024;
                            if (filesize >= 4000)
                            {
                                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailedFileUploadsize, Color.Red);
                                return;
                            }
                            else
                            {
                                FileUpload1.SaveAs(serverpath);
                            }
                        }
                        else
                        {
                            filename = Session["imageurl"].ToString();
                        }
                    }

                    if ((txtusername.Text.Length > 0) && (txtusername.Text != lblusername.Text))
                    {
                        if (vLecir.FindByuserName(txtusername.Text) != null)
                        {
                            PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errRepeatuserTitle, Color.Red);

                            return;
                        }
                    }

                    VEmployeesRepository vempirr = new VEmployeesRepository();
                    Employee             emp     = new Employee();

                    emp.EmployeeID = lblempid.Text.ToInt();

                    emp.FirstName    = txtname.Text;
                    emp.LastName     = txtlastname.Text;
                    emp.Gender       = RadioButtonList1.SelectedValue.ToInt();
                    emp.NationalCode = txtnationalcode.Text;
                    emp.DepartmentID = Session["newdep"].ToString().ToInt();
                    emp.RoleID       = Session["newrole"].ToString().ToInt();
                    if ((txtusername.Text.Length > 0) && (txtusername.Text != lblusername.Text))
                    {
                        emp.Username = txtusername.Text;
                    }
                    else
                    {
                        emp.Username = lblusername.Text;
                    }

                    //emp.Password = (txtpass.Text.Length > 0 ? FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5") : emp.Password);
                    if (txtpass.Text.Length > 0)
                    {
                        emp.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5");
                    }
                    else
                    {
                        emp.Password = Session["pass"].ToString();
                    }
                    emp.Status = (chkActiveAccount.Checked == true ? 0 : 1);

                    emp.ImageFileName = filename;
                    vempirr.Saveemp(emp);

                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgUpdateSuccessfull, Color.Green);
                }
                catch
                {
                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errUpdateFailed, Color.Red);
                }
            }
        }
Example #4
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            VEmployeesRepository emp = new VEmployeesRepository();

            if (emp.FindByuserName(txtmail.Text) != null)
            {
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errDuplicateUsername, Color.Red);
                return;
            }



            //  bool successfullCreateAccount = true;
            //try
            //{
            string serverpath = Server.MapPath(Request.ApplicationPath) + @"\file\" + PersonTools.CurrentPersianDateWithoutSlash() + PersonTools.CurrentTimeWithoutColons() + FileUpload1.FileName;
            string filename   = PersonTools.CurrentPersianDateWithoutSlash() + PersonTools.CurrentTimeWithoutColons() + FileUpload1.FileName;


            //VEmployeesRepository vstdir = new VEmployeesRepository();
            //if (vstdir.FindByLinkUrl(filename) != null)
            //{
            //    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailedFileUploadrepeat, Color.Red);

            //    return;
            //}
            //else
            //{

            if (FileUpload1.FileName.Length > 0)
            {
                //int filesize = FileUpload1.FileBytes.Length / 1024;
                //if (filesize >= 4000)
                //{
                //    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailedFileUploadsize, Color.Red);
                //    return;
                //}
                //else
                //{

                FileUpload1.SaveAs(serverpath);
                //  }
            }
            else
            {
                //  PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailedFileUploadempty, Color.Red);
                //  return;
                filename = "";
            }
            //   }



            Employee newemp = new Employee();

            newemp.DepartmentID = ddldep.SelectedValue.ToInt();
            newemp.RoleID       = ddlrole.SelectedValue.ToInt();
            newemp.FirstName    = txtname.Text;
            newemp.LastName     = txtlastname.Text;
            newemp.Gender       = RadioButtonList1.SelectedValue.ToInt();
            newemp.NationalCode = txtnationalcode.Text;


            newemp.ImageFileName = filename;
            newemp.FixTel        = txttel.Text;
            newemp.Email         = txtmail.Text;
            newemp.Mobile        = txtmobile.Text;

            VEmployeesRepository vstdirr = new VEmployeesRepository();

            vstdirr.Saveemp(newemp);


            clearform();
            PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgAddSuccessfull, Color.Green);
        }