Example #1
0
        private void BindGridData()
        {
            CustomerEntities jde = new CustomerEntities();
            var result           = from emp in jde.CustomerDatas
                                   select
                                   new
            {
                CustID  = emp.CustId,
                Name    = emp.Name,
                Country = emp.Country,
            };

            DataGrid.DataSource = result.ToList();
            DataGrid.DataBind();
        }
Example #2
0
 protected void Del_Click(object sender, EventArgs e)
 {
     try
     {
         CustomerData j = new CustomerData();
         j.CustId = Convert.ToInt32(CustID_text.Text);
         using (CustomerEntities jde = new CustomerEntities())
         {
             CustomerData del = jde.CustomerDatas.FirstOrDefault(d => (d.CustId == j.CustId));
             jde.CustomerDatas.Remove(del);
             jde.SaveChanges();
         }
         message.Text = "Deleted Sucessfully";
         //  BindGridData();
     }
     catch (Exception ex)
     {
         message.Text = "Somthing went wrong please check Employee ID details again.";
     }
 }
Example #3
0
        protected void Create_bttn_Click(object sender, EventArgs e)
        {
            try
            {
                CustomerData j = new CustomerData();
                j.CustId  = Convert.ToInt32(CustID_text.Text);
                j.Name    = Name_text.Text;
                j.Country = Country_text.Text;

                using (CustomerEntities jde = new CustomerEntities())
                {
                    jde.CustomerDatas.Add(j);
                    jde.SaveChanges();
                }
                message.Text = "Inserted Sucessfully";
                //  BindGridData();
            }
            catch (Exception ex)
            {
                message.Text = "Something went wrong";
            }
        }
Example #4
0
 protected void update_bttn_Click(object sender, EventArgs e)
 {
     // VisibilityCheck(true, true, true);
     try
     {
         CustomerData j = new CustomerData();
         using (CustomerEntities jde = new CustomerEntities())
         {
             j.CustId  = Convert.ToInt32(CustID_text.Text);
             j         = jde.CustomerDatas.FirstOrDefault(d => d.CustId == j.CustId);
             j.Name    = Name_text.Text;
             j.Country = Country_text.Text;
             jde.SaveChanges();
         }
         message.Text = "Updated Sucessfully";
         //  BindGridData();
     }
     catch (Exception ex)
     {
         message.Text = "Somthing went wrong, Employee Does not exist";
     }
 }