Exemplo n.º 1
0
        public VStudent FindByStdUsername(string username, string password, string stdusername)
        {
            WebServiceAccountsRepository webir       = new WebServiceAccountsRepository();
            WebServiceAccount            currentuser = webir.FindByUserName(username);

            if (currentuser != null)
            {
                if (currentuser.Password == password)
                {
                    VStudentsRepository depir = new VStudentsRepository();
                    return(depir.FindByuserName(stdusername));
                }
                else
                {
                    return(null);
                }
            }

            else
            {
                return(null);
            }
        }
Exemplo n.º 2
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);
                }
            }
        }
Exemplo n.º 3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            VStudentsRepository vstd = new VStudentsRepository();

            if (vstd.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;

                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
                    {
                        //  PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailedFileUploadempty, Color.Red);
                        //  return;
                        filename = "";
                    }
                }



                Student newstd = new Student();
                newstd.StudentCode  = txtstdcode.Text;
                newstd.FirstName    = txtname.Text;
                newstd.LastName     = txtlastname.Text;
                newstd.Gender       = RadioButtonList1.SelectedValue.ToInt();
                newstd.NationalCode = txtnationalcode.Text;
                newstd.FacultyID    = ddlfacultuy.SelectedValue.ToInt();
                newstd.LevelID      = ddllevel.SelectedValue.ToInt();
                newstd.FieldID      = ddlfield.SelectedValue.ToInt();
                newstd.TendencyID   = ddltendency.SelectedValue.ToInt();
                newstd.EntryTerm    = RadioButtonList2.SelectedValue.ToInt();
                newstd.Username     = txtusername.Text;
                newstd.Password     = FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5");

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


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


                clearform();
            }
            catch (System.Exception err)
            {
                //OnlineTools.ShowMessage(lblMessage, err.Message, Color.Red);
                successfullCreateAccount = false;

                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailed, Color.Red);
            }
            if (successfullCreateAccount)
            {
                // ClearForm();
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgAddSuccessfull, Color.Green);
            }
        }