Esempio n. 1
0
        protected void RegisterBt_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Username.Text) && !string.IsNullOrEmpty(Password.Text) && !string.IsNullOrEmpty(Password2.Text) && !string.IsNullOrEmpty(Email.Text))
            {
                using (CEntities db = new CEntities())
                {
                    Users reg = new Users();

                    reg.Email    = Email.Text;
                    reg.Username = Username.Text;
                    if (Password.Text.Equals(Password2.Text))

                    {
                        reg.Password = Password.Text;
                        db.Users.Add(reg);


                        db.SaveChanges();
                        Response.Write("<script language='javascript'>window.alert('You successfully registered');window.location='MainPage.aspx';</script>");
                    }

                    else
                    {
                        lblMessagePass.Text = "Your passwords are not matching";
                    }
                }
            }
            else
            {
                lblMessage.Text = "Fields should be filled";
            }
        }
Esempio n. 2
0
        protected void AddCust_Click(object sender, EventArgs e)
        {
            using (CEntities db = new CEntities())
            {
                if (!string.IsNullOrEmpty(NameTxt.Text) && !string.IsNullOrEmpty(PhoneTxt.Text))

                {
                    Customer cus = new Customer();

                    cus.UserId = (int)Session["UserID"];
                    cus.Name   = NameTxt.Text;
                    cus.Mail   = MailTxt.Text;
                    cus.Phone  = PhoneTxt.Text;
                    cus.Adress = AddressTxt.Text;

                    db.Customer.Add(cus);
                    db.SaveChanges();


                    Response.Write("<script language='javascript'>window.alert('Customer is added');window.location='ListCustomer.aspx';</script>");
                }
                else
                {
                    Response.Write("<script language='javascript'>alert('Fill the required information')</script>;");
                }
            }
        }
Esempio n. 3
0
        protected void UpdatePass_Click(object sender, EventArgs e)
        {
            string UId = Request.QueryString["uid"].ToString();

            if (!string.IsNullOrEmpty(ConfirmPassTxt.Text) && !string.IsNullOrEmpty(NewPassTxt.Text))
            {
                if (!ConfirmPassTxt.Text.Equals(NewPassTxt.Text))
                {
                    Response.Write("<script>alert('Passwords are not matching')</script>;");
                }
                else
                {
                    using (CEntities db = new CEntities())
                    {
                        Users rec = db.Users.Where(a => a.PasswordResetId.ToString() == UId).FirstOrDefault();
                        if (rec != null)
                        {
                            rec.Password        = NewPassTxt.Text;
                            rec.PasswordResetId = null;
                            db.SaveChanges();
                            Session["UserID"]   = rec.Id;
                            Session["Username"] = rec.Username;
                            Response.Redirect("/MainPage.aspx");
                        }
                    }
                }
            }
        }
        protected void btnCalendarDetail_Click(object sender, EventArgs e)
        {
            using (CEntities db = new CEntities())
            {
                string meetId = Request.QueryString["ID"].ToString();

                Meeting meet = db.Meeting.Where(a => a.Id.ToString() == meetId).FirstOrDefault();

                if (meet != null)
                {
                    byte meetviaId  = Convert.ToByte(dplMeetingVia.SelectedValue);
                    byte meetdoneId = Convert.ToByte(dplMeetingDone.SelectedValue);
                    int  newCusId   = Convert.ToInt16(dplCustomer.SelectedValue);
                    if (!string.IsNullOrEmpty(txtDateStart.Text) && !string.IsNullOrEmpty(txtDateEnd.Text))
                    {
                        meet.DateStart = Convert.ToDateTime(txtDateStart.Text);
                        meet.DateEnd   = Convert.ToDateTime(txtDateEnd.Text);
                    }
                    meet.CustomerId    = newCusId;
                    meet.MeetingDoneId = meetdoneId;
                    meet.MeetingViaId  = meetviaId;
                    meet.Description   = txtDesc.Text;
                    meet.Whom          = txtWhom.Text;
                    db.SaveChanges();

                    Response.Redirect("/Calendar.aspx");
                }
            }
        }
Esempio n. 5
0
        protected void UpdateProfile_Click(object sender, EventArgs e)
        {
            using (CEntities db = new CEntities())
            {
                int userID = Convert.ToInt32(Session["UserID"]);

                Users rec = db.Users.Where(a => a.Id == userID).FirstOrDefault();
                if (rec != null)
                {
                    if (!string.IsNullOrEmpty(NewUsernameTxt.Text))
                    {
                        rec.Username        = NewUsernameTxt.Text;
                        NewUsernameTxt.Text = "";
                        lblUsernameTxt.Text = rec.Username;
                    }
                    if (!string.IsNullOrEmpty(NewEMailTxt.Text))
                    {
                        rec.Email        = NewEMailTxt.Text;
                        NewEMailTxt.Text = "";
                        lblEMailTxt.Text = rec.Email;
                    }

                    Response.Write("<script>alert('You updated your information successfully')</script>");
                    db.SaveChanges();
                    Session["Username"] = rec.Username;
                }
            }
        }
Esempio n. 6
0
        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {
                using (CEntities db = new CEntities())
                {
                    int            id       = Convert.ToInt32(e.CommandArgument);
                    Customer       cus      = db.Customer.Where(a => a.Id == id).FirstOrDefault();
                    List <Meeting> meetlist = db.Meeting.Where(a => a.CustomerId == id).ToList();


                    if (cus != null)
                    {
                        db.Customer.Remove(cus);
                        foreach (Meeting m in meetlist)
                        {
                            db.Meeting.Remove(m);
                        }

                        db.SaveChanges();
                    }
                    List_Customers();
                }
            }
        }
Esempio n. 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //changePassTxt.Text = "To change password: "******"/Login.aspx");
         }
         else
         {
             lblUsernameTxt.Text = Session["Username"].ToString();
             using (CEntities db = new CEntities())
             {
                 int   userID = Convert.ToInt32(Session["UserID"]);
                 Users rec    = db.Users.Where(a => a.Id == userID).FirstOrDefault();
                 if (rec != null)
                 {
                     lblUsernameTxt.Text = rec.Username;
                     lblEMailTxt.Text    = rec.Email;
                 }
             }
         }
     }
 }
 protected void SavePassBtn_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(CurrentPasswordTxt.Text) && !string.IsNullOrEmpty(NewPassTxt.Text) && !string.IsNullOrEmpty(ConfirmPassTxt.Text))
     {
         using (CEntities db = new CEntities())
         {
             int   userID = Convert.ToInt32(Session["UserID"]);
             Users rec    = db.Users.Where(a => a.Id == userID).FirstOrDefault();
             if (rec != null)
             {
                 if (rec.Password.Equals(CurrentPasswordTxt.Text))
                 {
                     if (NewPassTxt.Text.Equals(ConfirmPassTxt.Text))
                     {
                         rec.Password = NewPassTxt.Text;
                         db.SaveChanges();
                         Response.Write("<script>alert('Password is updated')</script>");
                         Response.Redirect("/Login.aspx");
                     }
                     else
                     {
                         Response.Write("<script>alert('Passwords are not matching')</script>");
                     }
                 }
                 else
                 {
                     Response.Write("<script>alert('Password is wrong')</script>");
                 }
             }
         }
     }
 }
Esempio n. 9
0
        protected void Search_Click(object sender, EventArgs e)
        {
            List <VW_Meeting> list = null;

            using (CEntities db = new CEntities())
            {
                list = db.VW_Meeting.Where(a => a.CustomerName == txtSearch.Text).ToList();
            }

            rpt_demo.DataSource = list;
            rpt_demo.DataBind();
        }
Esempio n. 10
0
 private void Delete()
 {
     using (CEntities db = new CEntities())
     {
         Users rec = db.Users.Where(a => a.Username == txtLoginName.Text && a.Password == txtPassword.Text).FirstOrDefault();
         if (rec != null)
         {
             db.Users.Remove(rec);
             db.SaveChanges();
         }
     }
 }
Esempio n. 11
0
        private void NewAdd()
        {
            using (CEntities db = new CEntities())
            {
                Users rec = new Users();
                rec.Email    = "";
                rec.Username = "";

                db.Users.Add(rec);
                db.SaveChanges();
            }
        }
Esempio n. 12
0
        private List <Customer> List_Customers()
        {
            List <Customer> cuslist = null;

            using (CEntities db = new CEntities())
            {
                int UId = (Int32)Session["UserID"];
                cuslist = db.Customer.Where(a => a.UserId == UId).ToList();
            }
            rpt_demo.DataSource = cuslist;
            rpt_demo.DataBind();
            return(cuslist);
        }
Esempio n. 13
0
        private List <VW_Meeting> List_Meetings()
        {
            List <VW_Meeting> list = null;

            using (CEntities db = new CEntities())
            {
                int UId = (Int32)Session["UserID"];
                list = db.VW_Meeting.Where(a => a.UserId == UId).ToList();
            }

            rpt_demo.DataSource = list;
            rpt_demo.DataBind();
            return(list);
        }
Esempio n. 14
0
        private Users GetByID(int id)
        {
            Users rec = null;

            using (CEntities db = new CEntities())
            {
                id  = 1;
                rec = db.Users.Where(a => a.Id == id).FirstOrDefault();
                if (rec != null)
                {
                }
            }
            return(rec);
        }
Esempio n. 15
0
        public List <NCalendar> GetVisitCalendar(string dateStart, string dateEnd)
        {
            List <NCalendar> retval = new List <NCalendar>();
            DateTime?        dStart = null;
            DateTime?        dEnd   = null;

            if (!string.IsNullOrEmpty(dateStart))
            {
                dStart = Convert.ToDateTime(dateStart);
            }
            if (!string.IsNullOrEmpty(dateEnd))
            {
                dEnd = Convert.ToDateTime(dateEnd).AddDays(1);
            }


            List <VW_Meeting> list = null;

            using (CEntities db = new CEntities())
            {
                int      UId = Convert.ToInt32(Session["UserID"]);
                DateTime ds  = Convert.ToDateTime(dateStart);
                DateTime de  = Convert.ToDateTime(dateEnd);
                list = db.VW_Meeting.Where(a => a.UserId == UId && a.DateStart >= ds && a.DateEnd <= de).ToList();
                foreach (var item in list)
                {
                    NCalendar tmp = new NCalendar();
                    tmp.id       = item.Id;
                    tmp.title    = item.CustomerName;
                    tmp.start    = item.DateStart.ToString("yyyy-MM-dd HH:mm");
                    tmp.end      = item.DateEnd.ToString("yyyy-MM-dd HH:mm");
                    tmp.editable = true;
                    if (item.MeetingDoneId == 1)
                    {
                        tmp.color = "#FFB752";//TURUNCU
                    }
                    else if (item.MeetingDoneId == 2)
                    {
                        tmp.color = "#87B87F";//YEŞİL
                    }
                    else
                    {
                        tmp.color = "#B74635";//KIRMIZI
                    }
                    retval.Add(tmp);
                }
            }
            return(retval);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (!ISLOGIN)
                {
                    Response.Redirect("/Login.aspx");
                }
                else
                {
                    string meetId = Request.QueryString["ID"].ToString();

                    int UId = (Int32)Session["UserID"];

                    dplMeetingDone.Items.Insert(0, new ListItem("Choose meeting status", "0"));
                    dplMeetingDone.Items.Insert(1, new ListItem("Undefined", "1"));
                    dplMeetingDone.Items.Insert(2, new ListItem("Done", "2"));
                    dplMeetingDone.Items.Insert(3, new ListItem("Undone", "3"));

                    dplMeetingVia.Items.Insert(0, new ListItem("Choose meeting type", "0"));
                    dplMeetingVia.Items.Insert(1, new ListItem("Interview", "1"));
                    dplMeetingVia.Items.Insert(2, new ListItem("Phone", "2"));
                    dplMeetingVia.Items.Insert(3, new ListItem("E-Mail", "3"));

                    using (CEntities db = new CEntities())
                    {
                        Meeting meet = db.Meeting.Where(a => a.Id.ToString() == meetId).FirstOrDefault();
                        dplMeetingDone.SelectedValue = meet.MeetingDoneId.ToString();
                        dplMeetingVia.SelectedValue  = meet.MeetingViaId.ToString();

                        lblDesc.Text = meet.Description;
                        lblWhom.Text = meet.Whom;

                        List <Customer> cuslist = db.Customer.Where(a => a.UserId == UId).ToList();
                        if (!cuslist.Any())
                        {
                            Response.Write("<script language='javascript'>window.alert('You have to register customers');window.location='AddCustomer.aspx';</script>");
                        }
                        dplCustomer.DataSource     = cuslist;
                        dplCustomer.DataTextField  = "Name";
                        dplCustomer.DataValueField = "Id";
                        dplCustomer.DataBind();
                    }

                    lblUsername.Text = Session["Username"].ToString();
                }
            }
        }
Esempio n. 17
0
 protected void Repeater_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "Delete")
     {
         using (CEntities db = new CEntities())
         {
             int     id   = Convert.ToInt32(e.CommandArgument);
             Meeting meet = db.Meeting.Where(a => a.Id == id).FirstOrDefault();
             if (meet != null)
             {
                 db.Meeting.Remove(meet);
                 db.SaveChanges();
             }
             List_Meetings();
         }
     }
 }
Esempio n. 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string UId = Request.QueryString["uid"].ToString();

            if (String.IsNullOrEmpty(Request.QueryString["uid"]))
            {
                Response.Redirect("/Login.aspx");
            }
            else
            {
                using (CEntities db = new CEntities())
                {
                    Users rec = db.Users.Where(a => a.PasswordResetId.ToString() == UId).FirstOrDefault();
                    if (rec == null)
                    {
                        Response.AddHeader("The link is expired ", "URL=Login.aspx");
                    }
                }
            }
        }
Esempio n. 19
0
 protected void ResetPass_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(EMailTxt.Text))
     {
         using (CEntities db = new CEntities())
         {
             Users rec = db.Users.Where(a => a.Email == EMailTxt.Text).FirstOrDefault();
             if (rec != null)
             {
                 rec.PasswordResetId = Guid.NewGuid();
                 db.SaveChanges();
                 SendPasswordResetEmail(rec.Email, rec.Username, rec.PasswordResetId.ToString());
             }
             else
             {
                 Response.Write("<script>alert('User not found')</script>;");
             }
         }
     }
 }
Esempio n. 20
0
        protected void AddMeeting_Click(object sender, EventArgs e)
        {
            using (CEntities db = new CEntities())
            {
                if (!string.IsNullOrEmpty(txtDateStart.Text) && !string.IsNullOrEmpty(txtduration.Text))

                {
                    int     UId  = (Int32)Session["UserID"];
                    Meeting meet = new Meeting();


                    byte meetviaId  = Convert.ToByte(dplMeetingVia.SelectedValue);
                    byte meetdoneId = Convert.ToByte(dplMeetingDone.SelectedValue);
                    int  newCusId   = Convert.ToInt16(dplCustomer.SelectedValue);
                    int  duration   = Convert.ToInt32(txtduration.Text);

                    meet.UserId     = UId;
                    meet.CustomerId = newCusId;
                    meet.DateStart  = Convert.ToDateTime(txtDateStart.Text);
                    meet.DateEnd    = meet.DateStart.AddMinutes(duration);
                    if (!string.IsNullOrEmpty(txtDesc.Text) && !string.IsNullOrEmpty(txtWhom.Text))
                    {
                        meet.Description = txtDesc.Text;
                        meet.Whom        = txtWhom.Text;
                    }
                    meet.MeetingViaId  = meetviaId;
                    meet.MeetingDoneId = meetdoneId;


                    db.Meeting.Add(meet);
                    db.SaveChanges();


                    Response.Write("<script language='javascript'>window.alert('Meeting is created');window.location='ListMeeting.aspx';</script>");
                }
                else
                {
                    Response.Write("<script language='javascript'>alert('Fill the required information')</script>;");
                }
            }
        }
Esempio n. 21
0
        public string FirmVisitUpdateEventResize(string id, string milliseconds)
        {
            string retval = "Yetkisiz İşlem";

            using (CEntities db = new CEntities())
            {
                int     ID  = Convert.ToInt32(id);
                Meeting rec = db.Meeting.Where(a => a.Id == ID).FirstOrDefault();
                if (rec != null)
                {
                    rec.DateEnd = rec.DateEnd.AddMilliseconds(Convert.ToDouble(milliseconds));
                    db.SaveChanges();
                    retval = "OK";
                }
                else
                {
                    retval = "Kayıt bulunamadı!";
                }
                return(retval);
            }
        }
Esempio n. 22
0
        public string NewVisit(string date, string duration, string customerID, string isMonth)
        {
            string   retval    = "NOK";
            DateTime dStart    = Convert.ToDateTime(date);
            short    dDuration = Convert.ToInt16(duration);

            using (CEntities db = new CEntities())
            {
                Meeting rec = new Meeting();
                rec.UserId        = Convert.ToInt32(Session["UserID"]);
                rec.CustomerId    = Convert.ToInt32(customerID);
                rec.DateStart     = dStart;
                rec.DateEnd       = dStart.AddMinutes(dDuration);
                rec.MeetingViaId  = 1;
                rec.MeetingDoneId = 1;

                db.Meeting.Add(rec);
                db.SaveChanges();
            }
            retval = "OK";
            return(retval);
        }
Esempio n. 23
0
        private void GoLogin()
        {
            if (!string.IsNullOrEmpty(txtLoginName.Text) && !string.IsNullOrEmpty(txtPassword.Text))
            {
                using (CEntities db = new CEntities())
                {
                    Users rec = db.Users.Where(a => a.Email == txtLoginName.Text && a.Password == txtPassword.Text).FirstOrDefault();

                    if (rec != null)
                    {
                        Session["UserID"]   = rec.Id;
                        Session["Username"] = rec.Username;

                        if (chkRememberMe.Checked)
                        {
                            Response.Cookies["Username"].Value   = txtLoginName.Text;
                            Response.Cookies["Password"].Value   = txtPassword.Text;
                            Response.Cookies["Username"].Expires = DateTime.MaxValue;
                            Response.Cookies["Password"].Expires = DateTime.MaxValue;
                        }
                        else
                        {
                            Response.Cookies["Username"].Expires = DateTime.Now.AddDays(-1);
                            Response.Cookies["Password"].Expires = DateTime.Now.AddDays(-1);
                        }

                        Response.Redirect("/MainPage.aspx");
                    }


                    else
                    {
                        lblMessage.Text = "Could not found";
                        //Response.Write("<script>alert('Could not found')</script>;");
                    }
                }
            }
        }
Esempio n. 24
0
        public string FirmVisitUpdateEventDrop(string id, string milliseconds, string days)
        {
            string retval = "Yetkisiz İşlem";

            using (CEntities db = new CEntities())
            {
                int mId = Convert.ToInt32(id);
                //List<Meeting> list = db.Meeting.Where(a => a.CustomerId == Convert.ToInt32(id)).ToList();
                Meeting m = db.Meeting.Where(a => a.Id == mId).FirstOrDefault();
                if (m != null)
                {
                    m.DateStart = m.DateStart.AddDays(Convert.ToInt32(days)).AddMilliseconds(Convert.ToDouble(milliseconds));
                    m.DateEnd   = m.DateEnd.AddDays(Convert.ToInt32(days)).AddMilliseconds(Convert.ToDouble(milliseconds));
                    db.SaveChanges();
                    retval = "OK";
                }
                else
                {
                    retval = "Kayıt bulunamadı!";
                }
                return(retval);
            }
        }
Esempio n. 25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (!ISLOGIN)
                {
                    Response.Redirect("/Login.aspx");
                }
                else
                {
                    lblUsername.Text = Session["Username"].ToString();
                    using (CEntities db = new CEntities())
                    {
                        DateTime dts = DateTime.Now.Date;
                        DateTime dte = DateTime.Now.Date.AddDays(2);
                        int      UId = Convert.ToInt16(Session["UserID"]);


                        List <VW_Meeting> rec = db.VW_Meeting.Where(a => a.DateStart >= dts && a.DateStart < dte && a.UserId == UId).ToList();
                        rpt_demo.DataSource = rec;
                        rpt_demo.DataBind();
                    }


                    //yada
                    //using (CEntities db = new CEntities())
                    //{
                    //    int UserID = Convert.ToInt32(Session["UserID"]);
                    //    Users rec = db.Users.Where(a => a.Id == UserID).FirstOrDefault();
                    //    if (rec != null)
                    //    {
                    //        lblUserName.Text = rec.Username;
                    //    }
                    //}
                }
            }
        }