Beispiel #1
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            try
            {
                List <int> selectedRows = new List <int>();

                foreach (GridViewRow gvr in GridView1.Rows)
                {
                    if ((gvr.FindControl("CheckBox2") as CheckBox).Checked == true)
                    {
                        selectedRows.Add(gvr.Cells[0].Text.ToInt());
                    }
                }

                if (selectedRows.Count > 0)
                {
                    EmailContactsRepository dir = new EmailContactsRepository();
                    dir.DeleteEmailContact(selectedRows);
                    LoadEmailContactData(Session["UserID"].ToString(), Session["UserTypeID"].ToString());


                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgDeleteSuccessfull, Color.Green);
                }
            }
            catch
            {
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errDeleteFailed, Color.Red);
            }
        }
Beispiel #2
0
        protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
        {
            lblmessage.Text = "";
            if (txtsearch.Text.Length > 0)
            {
                if (DropDownList1.SelectedValue == "3")
                {
                    try
                    {
                        EmailContactsRepository dir = new EmailContactsRepository();

                        Session["ecetid"]    = dir.SearchpersonEmailTypeid(txtsearch.Text.ToInt(), Session["UserTypeID"].ToString().ToInt(), Session["UserID"].ToString().ToInt());
                        GridView1.DataSource = Session["ecetid"];
                        GridView1.DataBind();

                        lblrecordcount.Text       = string.Format("{0} : {1}", dir.EmailContactCount().ToString(), Resources.DashboardText.RecordCount);
                        lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["ecetid"] as DataTable).Rows.Count.ToString(), Resources.DashboardText.SelectRecordCount);
                    }
                    catch
                    {
                        PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errSearch, Color.Red);
                        lblrecordcount.Text       = string.Format("{0} : {1}", "0", Resources.DashboardText.RecordCount);
                        lblSelectedDataCount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.SelectRecordCount);
                    }
                }
                if (DropDownList1.SelectedValue == "4")
                {
                    try
                    {
                        EmailContactsRepository dir = new EmailContactsRepository();

                        Session["eceaid"]    = dir.SearchpersonEmailAddrress(txtsearch.Text.ToString(), Session["UserTypeID"].ToString().ToInt(), Session["UserID"].ToString().ToInt());
                        GridView1.DataSource = Session["eceaid"];
                        GridView1.DataBind();

                        lblrecordcount.Text       = string.Format("{0} : {1}", dir.EmailContactCount().ToString(), Resources.DashboardText.RecordCount);
                        lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["eceaid"] as DataTable).Rows.Count.ToString(), Resources.DashboardText.SelectRecordCount);
                    }
                    catch
                    {
                        PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errSearch, Color.Red);
                        lblrecordcount.Text       = string.Format("{0} : {1}", "0", Resources.DashboardText.RecordCount);
                        lblSelectedDataCount.Text = string.Format("{0} : {1}", "0", Resources.DashboardText.SelectRecordCount);
                    }
                }
            }
            else
            {
                LoadEmailContactData(Session["UserID"].ToString(), Session["UserTypeID"].ToString());
            }
        }
Beispiel #3
0
        public void LoadEmailContactData(string userid, string usertypeid)
        {
            try
            {
                EmailContactsRepository dir = new EmailContactsRepository();
                Session["EmailPersonContactData"] = dir.GetEmailpersonContactList(userid.ToInt(), usertypeid.ToInt());

                GridView1.DataSource = Session["EmailPersonContactData"];


                GridView1.DataBind();

                lblrecordcount.Text = string.Format("{0} : {1}", dir.EmailContactCount().ToString().ToFarsiNumber(), Resources.DashboardText.RecordCount);

                lblSelectedDataCount.Text = string.Format("{0} : {1}", (Session["EmailPersonContactData"] as DataTable).Rows.Count.ToString().ToFarsiNumber(), Resources.DashboardText.SelectRecordCount);

                switch (Session["UserTypeID"].ToString())
                {
                case "1":
                {
                    VStudentsRepository vstdir = new VStudentsRepository();
                    VStudent            std    = vstdir.FindByid(Session["UserID"].ToString().ToInt());
                    Label9.Text = "دانشجو" + ":" + std.FirstName + " " + std.LastName;
                }
                break;

                case "2":
                {
                    VLecturersRepository vlec = new VLecturersRepository();
                    VLecturer            lec  = vlec.FindByid(Session["UserID"].ToString().ToInt());
                    Label9.Text = "استاد" + ":" + lec.FirstName + " " + lec.LastName;
                }
                break;

                case "3":
                {
                    VEmployeesRepository vlec = new VEmployeesRepository();
                    VEmployee            emp  = vlec.FindByid(Session["UserID"].ToString().ToInt());
                    Label9.Text = "کارمند" + ":" + emp.FirstName + " " + emp.LastName;
                }
                break;
                }
            }
            catch
            {
                Redirector.Goto(Redirector.PageName.errorpage);
            }
        }
Beispiel #4
0
        protected void Button1_Click1(object sender, EventArgs e)
        {
            if (lblid.Text.Length > 0)
            {
                try
                {
                    EmailContactsRepository ecrir = new EmailContactsRepository();
                    if ((TextBox2.Text.Length > 0) && (TextBox2.Text != lblemailaddrress.Text))
                    {
                        if (ecrir.FindByEmailAddrress(TextBox2.Text) != null)
                        {
                            PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errRepeatemailTitle, Color.Red);

                            return;
                        }
                    }



                    //  EmailContactsRepository ecrir = new EmailContactsRepository();
                    EmailContact email = new EmailContact();
                    email.UserTypeID = Session["UserTypeID"].ToString().ToInt();
                    // email.UserID=ddluserid.SelectedValue.ToInt();
                    //  email.EmailTypeID = ddlemailtype.SelectedValue.ToInt();
                    email.UserID      = Session["UserID"].ToString().ToInt();
                    email.EmailTypeID = Session["newemailtype"].ToString().ToInt();

                    email.ID = lblid.Text.ToInt();
                    ecrir.SaveEmailContact(email);

                    if ((TextBox2.Text.Length > 0) && (TextBox2.Text != lblemailaddrress.Text))
                    {
                        email.EmailAddrress = TextBox2.Text.Trim();
                    }


                    clearform();


                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgUpdateSuccessfull, Color.Green);
                }
                catch
                {
                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errUpdateFailed, Color.Red);
                }
            }
        }
Beispiel #5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            EmailContactsRepository email = new EmailContactsRepository();

            if (email.FindByEmailAddrress(TextBox1.Text) != null)
            {
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errDuplicateUsername, Color.Red);
                return;
            }



            bool successfullCreateAccount = true;


            try
            {
                EmailContact newcontact = new EmailContact();
                newcontact.UserTypeID = lblusertypeid.Text.ToInt();

                newcontact.UserID        = lbluserid.Text.ToInt();
                newcontact.EmailTypeID   = ddlemailtype.SelectedValue.ToInt();
                newcontact.EmailAddrress = TextBox1.Text.Trim();

                EmailContactsRepository ecrir = new EmailContactsRepository();
                ecrir.SaveEmailContact(newcontact);



                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);
            }
        }
Beispiel #6
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            try
            {
                List <int> selectedRows = new List <int>();

                foreach (GridViewRow gvr in GridView1.Rows)
                {
                    if ((gvr.FindControl("CheckBox2") as CheckBox).Checked == true)
                    {
                        selectedRows.Add(gvr.Cells[0].Text.ToInt());
                    }
                }

                if (selectedRows.Count > 0)
                {
                    VLecturersRepository vstdir = new VLecturersRepository();
                    vstdir.Deletelec(selectedRows);
                    //   vstdir.Deletelecturer(selectedRows);
                    LoadStdData();

                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgDeleteSuccessfull, Color.Green);


                    EmailContactsRepository emrir = new EmailContactsRepository();
                    emrir.DeletepersonEmailContact(selectedRows);
                    LoadStdData();

                    PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgDeleteSuccessfull, Color.Green);

                    TelContactsRepository trir = new TelContactsRepository();
                    trir.DeletepersonTelContact(selectedRows);
                    LoadStdData();
                }
            }
            catch
            {
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errDeleteFailed, Color.Red);
            }
        }
Beispiel #7
0
        public EmailContact FindByEmailContactID(string username, string password, int id)
        {
            WebServiceAccountsRepository webir       = new WebServiceAccountsRepository();
            WebServiceAccount            currentuser = webir.FindByUserName(username);

            if (currentuser != null)
            {
                if (currentuser.Password == password)
                {
                    EmailContactsRepository depir = new EmailContactsRepository();
                    return(depir.FindByid(id));
                }
                else
                {
                    return(null);
                }
            }

            else
            {
                return(null);
            }
        }
Beispiel #8
0
        public DataTable GetEmailContact(string username, string password)
        {
            WebServiceAccountsRepository webir       = new WebServiceAccountsRepository();
            WebServiceAccount            currentuser = webir.FindByUserName(username);

            if (currentuser != null)
            {
                if (currentuser.Password == password)
                {
                    EmailContactsRepository depir = new EmailContactsRepository();
                    return(depir.GetAllEmailContacts());
                }
                else
                {
                    return(null);
                }
            }

            else
            {
                return(null);
            }
        }
Beispiel #9
0
        public void loadform()
        {
            try
            {
                EmailContactsRepository ecrir = new EmailContactsRepository();
                EmailContact            email = ecrir.FindByid(Session["ID"].ToString().ToInt());
                lblid.Text           = email.ID.ToString();
                lbluserid.Text       = Session["UserID"].ToString();
                lblusertypeid.Text   = Session["UserTypeID"].ToString();
                Session["EmailType"] = email.EmailTypeID.ToString();

                lblemailaddrress.Text = email.EmailAddrress;

                Session["newemailtype"] = email.EmailTypeID.ToString();


                switch (Session["UserTypeID"].ToString())
                {
                case "1":
                {
                    VStudentsRepository vstdir = new VStudentsRepository();
                    VStudent            std    = vstdir.FindByid(Session["UserID"].ToString().ToInt());
                    Label9.Text = "دانشجو" + ":" + std.FirstName + " " + std.LastName;
                }
                break;

                case "2":
                {
                    VLecturersRepository vlec = new VLecturersRepository();
                    VLecturer            lec  = vlec.FindByid(Session["UserID"].ToString().ToInt());
                    Label9.Text = "استاد" + ":" + lec.FirstName + " " + lec.LastName;
                }
                break;

                case "3":
                {
                    VEmployeesRepository vlec = new VEmployeesRepository();
                    VEmployee            emp  = vlec.FindByid(Session["UserID"].ToString().ToInt());
                    Label9.Text = "کارمند" + ":" + emp.FirstName + " " + emp.LastName;
                }
                break;
                }



                EmailTypesRepository etir      = new EmailTypesRepository();
                EmailType            emailtype = etir.FindByid(Session["EmailType"].ToString().ToInt());
                if (emailtype != null)
                {
                    lblEmailtype.Text = emailtype.EmailTypeTitle;
                    // Label7.Text = std.FirstName.ToString() + " " + std.LastName.ToString();
                }
                else
                {
                    Redirector.Goto(Redirector.PageName.errorpage);
                }


                EmailTypesRepository etr = new EmailTypesRepository();
                DataTable            dt2 = etr.GetAllEmailTypes();
                ddlemailtype.Items.Clear();

                foreach (DataRow dr in dt2.Rows)
                {
                    ddlemailtype.Items.Add(new ListItem(dr["EmailTypeTitle"].ToString(), dr["EmailTypeID"].ToString()));
                }
            }
            catch
            {
                Redirector.Goto(Redirector.PageName.errorpage);
            }
        }
Beispiel #10
0
        public void LoadData(string id)
        {
            try
            {
                EmailContactsRepository ecrir = new EmailContactsRepository();
                EmailContact            email = ecrir.FindByid(id.ToInt());
                lblid.Text           = email.ID.ToString();
                Session["UserID"]    = email.UserID.ToString();
                Session["EmailType"] = email.EmailTypeID.ToString();
                Session["UserType"]  = email.UserTypeID.ToString();

                lblEmailaddrress.Text   = email.EmailAddrress.ToString();
                Session["newuserid"]    = email.UserID.ToString();
                Session["newemailtype"] = email.EmailTypeID.ToString();
                VStudentsRepository vstdir = new VStudentsRepository();
                VStudent            std    = vstdir.FindByid(Session["UserID"].ToString().ToInt());
                if (std != null)
                {
                    Label7.Text = std.FirstName.ToString() + " " + std.LastName.ToString();
                }
                else
                {
                    Redirector.Goto(Redirector.PageName.errorpage);
                }



                EmailTypesRepository etir      = new EmailTypesRepository();
                EmailType            emailtype = etir.FindByid(Session["EmailType"].ToString().ToInt());
                if (emailtype != null)
                {
                    lblEmailtype.Text = emailtype.EmailTypeTitle;
                    // Label7.Text = std.FirstName.ToString() + " " + std.LastName.ToString();
                }
                else
                {
                    Redirector.Goto(Redirector.PageName.errorpage);
                }


                EmailTypesRepository etr = new EmailTypesRepository();
                DataTable            dt2 = etr.GetAllEmailTypes();
                ddlemailtype.Items.Clear();

                foreach (DataRow dr in dt2.Rows)
                {
                    ddlemailtype.Items.Add(new ListItem(dr["EmailTypeTitle"].ToString(), dr["EmailTypeID"].ToString()));
                }



                switch ((Session["UserType"].ToString()))
                {
                case "1":
                {
                    DropDownList1.SelectedValue = "1";
                    VStudentsRepository vstd  = new VStudentsRepository();
                    DataTable           dtstd = vstd.GetAllstd();

                    ddluserid.Items.Clear();
                    foreach (DataRow dr in dtstd.Rows)
                    {
                        ddluserid.Items.Add(new ListItem(dr["FirstName"].ToString() + " " + dr["LastName"].ToString(), dr["StudentID"].ToString()));
                    }
                }
                break;

                case "2":
                {
                    DropDownList1.SelectedValue = "2";

                    VLecturersRepository vlrir = new VLecturersRepository();
                    DataTable            dtlec = vlrir.GetAllLec();
                    ddluserid.Items.Clear();
                    foreach (DataRow dr in dtlec.Rows)
                    {
                        ddluserid.Items.Add(new ListItem(dr["FirstName"].ToString() + " " + dr["LastName"].ToString(), dr["LecturerID"].ToString()));
                    }
                }
                break;

                case "3":
                {
                    DropDownList1.SelectedValue = "3";
                    VEmployeesRepository verir = new VEmployeesRepository();
                    DataTable            dtemp = verir.GetAllEmp();
                    ddluserid.Items.Clear();
                    foreach (DataRow dr in dtemp.Rows)
                    {
                        ddluserid.Items.Add(new ListItem(dr["FirstName"].ToString() + " " + dr["LastName"].ToString(), dr["EmployeeID"].ToString()));
                    }
                }
                break;
                }
            }
            catch
            {
                Redirector.Goto(Redirector.PageName.errorpage);
            }
        }