public ActionResult Create(IncomeViewModels collection)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Income toDB = new Income();
                    toDB.Active            = 1;
                    toDB.IncomeDescription = collection.IncomeDescription;
                    toDB.IncomeName        = collection.IncomeName;
                    //toDB.IncomeValue = collection.IncomeValue;
                    toDB.Order = collection.Order;
                    incomeBL.InsertIncome(toDB);

                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", "Error.");
                    return(View(collection));
                }
            }
            catch
            {
                ModelState.AddModelError("", "Error.");
                return(View(collection));
            }
        }
Example #2
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtName.Text.Trim().Length > 0)
         {
             income.Income = txtName.Text.Trim();
             income.InsertIncome();
             lblMsg.Text = "Inserted...!";
             BindData();
         }
         else
         {
             lblMsg.Text = "Enter Value...";
             txtName.Focus();
         }
     }
     catch (Exception ex)
     {
         // lblMsg.Text=ex.Message.ToString();
         lblMsg.Text = "Value Is Already Present...!";
     }
 }