Example #1
0
 public WorkerController(DataContext _context, IHostingEnvironment _hosting, IMemoryCache _cache)
 {
     context   = _context;
     hosting   = _hosting;
     cache     = _cache;
     workerBll = new WorkerBLL(_context);
 }
Example #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(this.textBox1.Text) || String.IsNullOrEmpty(this.textBox2.Text) || String.IsNullOrEmpty(this.textBox3.Text) || String.IsNullOrEmpty(this.textBox4.Text) || String.IsNullOrEmpty(this.comboBox1.Text) || String.IsNullOrEmpty(this.dateTimePicker1.Text))
     {
         MessageBox.Show("Please Enter Valid Record!!!");
     }
     else
     {
         try
         {
             Worker w = new Worker();
             w.FullName   = this.textBox1.Text;
             w.CNIC       = this.textBox2.Text;
             w.Address    = this.textBox3.Text;
             w.MobileNo   = this.textBox4.Text;
             w.EmgContact = comboBox1.Text;
             w.JoinDate   = Convert.ToDateTime(dateTimePicker1.Value.Date);
             w.IsActive   = this.checkBox2.Text;
             WorkerBLL wbll = new WorkerBLL();
             if (wbll.insertWorker(w))
             {
                 MessageBox.Show("Worker Successfully Added!!!!!");
             }
             else
             {
                 MessageBox.Show("Failed To Add!!!!");
             }
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Example #3
0
        private void button3_Click(object sender, EventArgs e)
        {
            FormSearchWorker w = new FormSearchWorker();
            Worker           selectedWorker = new Worker();

            w.ShowDialog();
            if (w.select)
            {
                selectedWorker.FullName = w.selectedW.FullName;
                selectedWorker.CNIC     = w.selectedW.CNIC;
                WorkerBLL wb = new WorkerBLL();
                if (wb.delWorker(selectedWorker))
                {
                    MessageBox.Show("Successfully Deleted....");
                }
                else
                {
                    MessageBox.Show("Unsuccessful.....");
                }
            }
        }
 protected void delete_Click(object sender, EventArgs e)
 {
     if (this.name.Text == "")
     {
         Response.Write("<script> alert('Full Name is required for deletion'); </script>");
         this.clearForm();
     }
     else
     {
         Worker worker = new Worker();
         worker.FullName = Convert.ToString(this.name.Text);
         WorkerBLL workers = new WorkerBLL();
         if (workers.delWorker(worker) == true)
         {
             Response.Write("<script> alert('User Deleted'); </script>");
             this.clearForm();
         }
         else
         {
             Response.Write("<script> alert('Deletion failed'); </script>");
             this.clearForm();
         }
     }
 }
        protected void Add_Click(object sender, EventArgs e)
        {
            if (this.add.Text == "Update")
            {
                if (this.name.Text != "")
                {
                    worker1.FullName = this.name.Text;
                }
                else
                {
                    Response.Write("<script> alert('Empty Field is not allow fill all fields'); </script> ");
                }
                if (this.CNIC.Text != "")
                {
                    worker1.CNIC = this.CNIC.Text;
                }
                else
                {
                    Response.Write("<script> alert('Empty Field is not allow fill all fields Except UserName'); </script> ");
                }
                if (this.address.Text != "")
                {
                    worker1.Address = this.address.Text;
                }
                else
                {
                    Response.Write("<script> alert('Empty Field is not allow fill all fields'); </script> ");
                }
                if (this.mobileNo.Text != "")
                {
                    worker1.MobileNo = this.mobileNo.Text;
                }
                else
                {
                    Response.Write("<script> alert('Empty Field is not allow fill all fields'); </script> ");
                }
                if (this.emg.Text != "")
                {
                    worker1.EmgContact = this.emg.Text;
                }
                else
                {
                    Response.Write("<script> alert('Empty Field is not allow fill all fields'); </script> ");
                }
                if (this.date.Text != "")
                {
                    worker1.JoinDate = Convert.ToDateTime(this.date.Text);
                }
                else
                {
                    Response.Write("<script> alert('Empty Field is not allow fill all fields'); </script> ");
                }

                WorkerBLL wbll = new WorkerBLL();
                try
                {
                    if (wbll.updateWorker(worker1, name3))
                    {
                        Response.Write("<script> alert('Updated Successfully'); </script> ");
                        this.add.Text = "Add";
                    }
                    else
                    {
                        Response.Write("<script> alert('Updated Successfully'); </script> ");
                        this.add.Text = "Add";
                    }
                    this.clearForm();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                if (String.IsNullOrEmpty(this.name.Text) || String.IsNullOrEmpty(this.CNIC.Text) || String.IsNullOrEmpty(this.address.Text) || String.IsNullOrEmpty(this.emg.Text) || String.IsNullOrEmpty(this.mobileNo.Text) || String.IsNullOrEmpty(this.date.Text))
                {
                    Response.Write("<script> alert('Fill the required all fields'); </script> ");
                }
                else
                {
                    Worker w = new Worker();
                    w.FullName   = this.name.Text;
                    w.CNIC       = this.CNIC.Text;
                    w.EmgContact = this.emg.Text;
                    w.IsActive   = this.IsActive.Text;
                    w.JoinDate   = Convert.ToDateTime(this.date.Text);
                    w.MobileNo   = this.mobileNo.Text;
                    w.Address    = this.address.Text;
                    WorkerBLL wbll = new WorkerBLL();
                    try
                    {
                        if (wbll.insertWorker(w))
                        {
                            Response.Write("<script> alert('Successfully saved'); </script> ");
                            this.clearForm();
                        }
                        else
                        {
                            Response.Write("<script> alert('Failed To Save'); </script> ");
                            this.clearForm();
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }