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 (lbllecid.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;

                    VLecturersRepository vLecir = new VLecturersRepository();

                    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;
                        }
                    }

                    VLecturersRepository vLecirr = new VLecturersRepository();
                    Lecturer             Lec     = new Lecturer();

                    Lec.LecturerID = lbllecid.Text.ToInt();

                    Lec.FirstName    = txtname.Text;
                    Lec.LastName     = txtlastname.Text;
                    Lec.Gender       = RadioButtonList1.SelectedValue.ToInt();
                    Lec.NationalCode = txtnationalcode.Text;
                    Lec.FacultyID    = Session["newfacultyid"].ToString().ToInt();

                    Lec.FieldID    = Session["newfieldid"].ToString().ToInt();
                    Lec.TendencyID = Session["newtenid"].ToString().ToInt();
                    if ((txtusername.Text.Length > 0) && (txtusername.Text != lblusername.Text))
                    {
                        Lec.Username = txtusername.Text;
                    }
                    else
                    {
                        Lec.Username = lblusername.Text;
                    }
                    //Lec.Password = (txtpass.Text.Length > 0 ? FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5") : Lec.Password);
                    if (txtpass.Text.Length > 0)
                    {
                        Lec.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5");
                    }
                    else
                    {
                        Lec.Password = Session["pass"].ToString();
                    }
                    Lec.Status        = (chkActiveAccount.Checked == true ? 0 : 1);
                    Lec.ImageFileName = filename;
                    vLecirr.Savestd(Lec);
                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgUpdateSuccessfull, Color.Green);
                }
                catch
                {
                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errUpdateFailed, Color.Red);
                }
            }
        }