public ActionResult Add(Customer customer, HttpPostedFileBase UploadImage)
 {
     try
     {
         if (UploadImage != null)
         {
             customer.Image = new byte[UploadImage.ContentLength];
             UploadImage.InputStream.Read(customer.Image, 0, UploadImage.ContentLength);
         }
         var added = _customer.Add(customer);
         if (added)
         {
             ViewBag.SMsg = "Save Success.";
         }
         else
         {
             ViewBag.FMsg = "Failed";
         }
     }
     catch (Exception exception)
     {
         ViewBag.FMsg = exception.Message;
     }
     ModelState.Clear();
     return(View());
 }
        private void addButton_Click(object sender, EventArgs e)
        {
            try
            {
                //Empty condition area
                if (String.IsNullOrEmpty(idTextBox.Text))
                {
                    MessageBox.Show("Id Can not be Empty!!!");
                    return;
                }
                if (String.IsNullOrEmpty(nameTextBox.Text))
                {
                    MessageBox.Show("Name Can not be Empty!!!");
                    return;
                }
                if (String.IsNullOrEmpty(addressTextBox.Text))
                {
                    MessageBox.Show("Address Can not be Empty!!!");
                    return;
                }
                if (String.IsNullOrEmpty(contactTextBox.Text))
                {
                    MessageBox.Show("contact Can not be Empty!!!");
                    return;
                }

                //Check UNIQUE
                if (_customerBll.IsContactExists(idTextBox.Text))
                {
                    MessageBox.Show("Id " + idTextBox.Text + " is Already Exists!");
                    return;
                }
                if (_customerBll.IsContactExists(nameTextBox.Text))
                {
                    MessageBox.Show("Name " + nameTextBox.Text + " is Already Exists!");
                    return;
                }
                if (_customerBll.IsContactExists(contactTextBox.Text))
                {
                    MessageBox.Show("Conact " + contactTextBox.Text + " is Already Exists!");
                    return;
                }


                //Add/Insert Item
                bool isAdded = _customerBll.Add(Convert.ToInt32(idTextBox.Text), nameTextBox.Text, addressTextBox.Text, Convert.ToInt32(contactTextBox.Text));

                if (isAdded)
                {
                    MessageBox.Show("Saved");
                }
                else
                {
                    MessageBox.Show("Not Saved");
                }

                //showDataGridView.DataSource = dataTable;
                showDataGridView.DataSource = _customerBll.Display();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }