Ejemplo n.º 1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (hid.Value == "Update")
                {
                    TrackerCompany coy = null; bool rst = false;
                    coy = LookUpBLL.GetTrackerCompany(Convert.ToInt32(txtID.Text));
                    if (coy != null)
                    {
                        coy.Name = txtDept.Text.ToUpper();;
                        rst      = LookUpBLL.UpdateTrackerCompany(coy);
                        if (rst != false)
                        {
                            BindGrid();
                            success.Visible   = true;
                            success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>&times;</button> Record updated successfully!!.";
                            return;
                        }
                    }

                    else
                    {
                        error.Visible   = true;
                        error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>&times;</button>Record could Not updated. Kindly try again. If error persist contact Administrator!!.";
                    }
                }
                else
                {
                    string com = "";
                    com = txtDept.Text;

                    bool           result = false;
                    TrackerCompany coy    = new TrackerCompany();
                    coy.Name = com.ToUpper();
                    result   = LookUpBLL.AddTrackerCompany(coy);
                    if (result)
                    {
                        BindGrid();
                        txtDept.Text = "";

                        success.Visible   = true;
                        success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>&times;</button> Record added successfully!!.";
                        return;
                    }
                    else
                    {
                        error.Visible   = true;
                        error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>&times;</button>Record could Not added. Kindly try again. If error persist contact Administrator!!.";
                    }
                }
            }
            catch (Exception ex)
            {
                error.Visible   = true;
                error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button> An error occurred. kindly try again!!!";
                Utility.WriteError("Error: " + ex.Message);
            }
        }
Ejemplo n.º 2
0
 public static bool AddTrackerCompany(TrackerCompany coy)
 {
     try
     {
         using (FleetMgtSysDBEntities db = new FleetMgtSysDBEntities())
         {
             db.TrackerCompanies.Add(coy);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         // Utility.WriteError("Error Msg: " + ex.Message);
         throw ex;
     }
 }
Ejemplo n.º 3
0
 public static bool UpdateTrackerCompany(TrackerCompany coy)
 {
     try
     {
         bool rst = false;
         using (var db = new FleetMgtSysDBEntities())
         {
             db.TrackerCompanies.Attach(coy);
             db.Entry(coy).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             rst = true;
         }
         return(rst);
     }
     catch (Exception ex)
     {
         Utility.WriteError("Error Msg: " + ex.InnerException);
         throw ex;
     }
 }