Пример #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         try
         {
             TechnetworkEntities db = new TechnetworkEntities();
             var empId = int.Parse(Session["EmployeeId"].ToString());
             if (!string.IsNullOrEmpty(empId.ToString()))
             {
                 var employee = db.Employees.Where(x => x.Id == empId).FirstOrDefault();
                 Empnm.Text      = employee.Name;
                 EmpEmail.Text   = employee.EmailId;
                 EmpPass.Text    = employee.Password;
                 EmpPhone.Text   = employee.Phone_number;
                 EmpAddress.Text = employee.Address;
             }
         }
         catch (Exception ex)
         {
             Label1.Text      = $"Session expired. Please signIn and retry.";
             Label1.ForeColor = System.Drawing.Color.Red;
             Label1.Visible   = true;
         }
     }
 }
        protected void Btn_submit_Click(object sender, EventArgs e)
        {
            try
            {
                TechnetworkEntities db      = new TechnetworkEntities();
                Service             service = new Service();
                service.Details               = TextBox5.Text;
                service.Service_cost          = decimal.Parse(TextBox4.Text);
                service.Service_name          = TextBox1.Text;
                service.Service_provider_name = TextBox2.Text;
                service.Servicing_last_date   = DateTime.Parse(TextBox3.Text);

                db.Services.Add(service);
                db.SaveChanges();

                TextBox1.Text  = "";
                TextBox2.Text  = "";
                TextBox3.Text  = "";
                TextBox4.Text  = "";
                TextBox5.Text  = "";
                Label1.Text    = "Service successfully posted";
                Label1.Visible = true;
            }catch (Exception ex)
            {
                Label1.Text    = "Something went wrong. Service is not posted. ";
                Label1.Visible = true;
            }
        }
        protected void Sbmt_btn_Click(object sender, EventArgs e)
        {
            try
            {
                TechnetworkEntities db        = new TechnetworkEntities();
                Developer           developer = new Developer();
                developer.Developer_name = Devnm.Text;
                developer.Developer_code = DevCode.Text;
                developer.Email_id       = DevEmail.Text;
                developer.Phone_number   = DevPhone.Text;
                developer.Designation    = DevDesg.Text;
                developer.Details        = DevDet.Text;
                developer.Address        = DevAdd.Text;
                db.Developers.Add(developer);
                db.SaveChanges();

                Label1.Text    = $"{Devnm.Text} successfully added";
                Devnm.Text     = "";
                DevEmail.Text  = "";
                DevPhone.Text  = "";
                DevDet.Text    = "";
                DevDesg.Text   = "";
                DevAdd.Text    = "";
                DevCode.Text   = "";
                Label1.Visible = true;
            }
            catch (Exception ex)
            {
                Label1.Text      = $"Something went wrong. Developer is not added. Error: {ex.Message} ";
                Label1.ForeColor = System.Drawing.Color.Red;
                Label1.Visible   = true;
            }
        }
        protected void Sbmt_btn_Click(object sender, EventArgs e)
        {
            try
            {
                TechnetworkEntities db      = new TechnetworkEntities();
                Product             product = new Product();
                product.Details         = productDet.Text;
                product.Price           = decimal.Parse(ProductPrc.Text);
                product.Product_name    = productnm.Text;
                product.Storage_require = ProdctStrg.Text;

                db.Products.Add(product);
                db.SaveChanges();
                Label1.Text     = $"{productnm.Text} successfully posted";
                productDet.Text = "";
                ProductPrc.Text = "";
                productnm.Text  = "";
                ProdctStrg.Text = "";


                Label1.Visible = true;
            }
            catch (Exception ex)
            {
                Label1.Text    = $"Something went wrong. Service is not posted. Error: {ex.Message} ";
                Label1.Visible = true;
            }
        }
Пример #5
0
        protected void Sbmt_btn_Click(object sender, EventArgs e)
        {
            TechnetworkEntities db = new TechnetworkEntities();

            if (db.Admins.Where(x => x.EmailId == EmailId.Text && x.Password == Password.Text).Any())
            {
                Session["Authorizer"] = "Admin";
                Session["AdminName"]  = db.Admins.Where(x => x.EmailId == EmailId.Text && x.Password == Password.Text)
                                        .Select(z => z.Name).FirstOrDefault();
                Response.Redirect("Admin.aspx");
            }
            else if (db.Employees.Where(x => x.EmailId == EmailId.Text && x.Password == Password.Text).Any())
            {
                Session["Authorizer"]   = "Employee";
                Session["EmployeeName"] = db.Employees.Where(x => x.EmailId == EmailId.Text && x.Password == Password.Text)
                                          .Select(z => z.Name).FirstOrDefault();
                Session["EmployeeId"] = db.Employees.Where(x => x.EmailId == EmailId.Text && x.Password == Password.Text)
                                        .Select(z => z.Id).FirstOrDefault();
                Response.Redirect("Employee.aspx");
            }
            else
            {
                Session["Authorizer"] = "";
            }
        }
Пример #6
0
        protected void Sbmt_btn_Click(object sender, EventArgs e)
        {
            try
            {
                TechnetworkEntities db = new TechnetworkEntities();
                var empId = int.Parse(Session["EmployeeId"].ToString());
                if (!string.IsNullOrEmpty(empId.ToString()))
                {
                    Model.Employee employee = db.Employees.Where(x => x.Id == empId).FirstOrDefault();
                    employee.Name = Empnm.Text;
                    if (!string.IsNullOrEmpty(EmpPass.Text))
                    {
                        employee.Password = EmpPass.Text;
                    }

                    employee.EmailId      = EmpEmail.Text;
                    employee.Phone_number = EmpPhone.Text;
                    employee.Address      = EmpAddress.Text;
                    employee.Designation  = EmpDesg.Text;
                    employee.Details      = EmpDet.Text;

                    db.SaveChanges();

                    Label1.Text = $"Congrats {Empnm.Text}, your profile is successfully updated";

                    Label1.Visible = true;
                }
                else
                {
                    Label1.Text    = $"Session expired. Please signIn and retry.";
                    Label1.Visible = true;
                }
            }
            catch (Exception ex)
            {
                Label1.Text      = $"Something went wrong. Service is not posted. Error: {ex.Message} ";
                Label1.ForeColor = System.Drawing.Color.Red;
                Label1.Visible   = true;
            }
        }
Пример #7
0
        protected void Sbmt_btn_Click(object sender, EventArgs e)
        {
            try
            {
                TechnetworkEntities db       = new TechnetworkEntities();
                Model.Employee      employee = new Model.Employee();
                employee.Name = Empnm.Text;
                if (!string.IsNullOrEmpty(EmpPass.Text))
                {
                    employee.Password = EmpPass.Text;
                }
                else
                {
                    Random rd = new Random();
                    employee.Password = $"Pass@{rd.Next(1111, 9999).ToString()}";
                }
                employee.EmailId      = EmpEmail.Text;
                employee.Phone_number = EmpPhone.Text;
                employee.Designation  = EmpDesg.Text;
                employee.Details      = EmpDet.Text;
                db.Employees.Add(employee);
                db.SaveChanges();

                Label1.Text    = $"{Empnm.Text} successfully added";
                Empnm.Text     = "";
                EmpEmail.Text  = "";
                EmpPhone.Text  = "";
                EmpPass.Text   = "";
                EmpDet.Text    = "";
                EmpDesg.Text   = "";
                Label1.Visible = true;
            }
            catch (Exception ex)
            {
                Label1.Text      = $"Something went wrong. Employee is not added. Error: {ex.Message} ";
                Label1.ForeColor = System.Drawing.Color.Red;
                Label1.Visible   = true;
            }
        }
Пример #8
0
        public List <Service> ListOfServices()
        {
            TechnetworkEntities db = new TechnetworkEntities();

            return(db.Services.Distinct().ToList());
        }
Пример #9
0
        public List <Developer> ListOfDevelopers()
        {
            TechnetworkEntities db = new TechnetworkEntities();

            return(db.Developers.Distinct().ToList());
        }
        public List <Model.Employee> ListOfEmployees()
        {
            TechnetworkEntities db = new TechnetworkEntities();

            return(db.Employees.Distinct().ToList());
        }
        public List <Product> prolist()
        {
            TechnetworkEntities db = new TechnetworkEntities();

            return(db.Products.Distinct().ToList());
        }