예제 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            tblExpens tblExpens = db.tblExpenses.Find(id);

            db.tblExpenses.Remove(tblExpens);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #2
0
 public ActionResult Edit([Bind(Include = "IDExpense,DatePosted,ExpenseDate,ORNumber,IDVendor,Particulars,WithReceipt,IDAccount,EncodedBy,IsVerified,ChargeToCodep,VATSales,VATAmount,VATExempt,Amount,PostedDate,ChargedToCodep,TIN")] tblExpens tblExpens)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblExpens).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblExpens));
 }
예제 #3
0
        public tblExpens Addexp(decimal amount)
        {
            var add = new tblExpens()
            {
                Year        = DateTime.Now.Year,
                Month       = DateTime.Now.Month.ToString(),
                ExpenseDate = DateTime.Now.Date,
                Amount      = amount,
            };

            return(add);
        }
예제 #4
0
        // GET: Expens/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblExpens tblExpens = db.tblExpenses.Find(id);

            if (tblExpens == null)
            {
                return(HttpNotFound());
            }
            return(View(tblExpens));
        }
예제 #5
0
 public void addexpense(tblExpens obj)
 {
     context.tblExpenses.Add(obj);
 }
예제 #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtExpName.Text == string.Empty && txtExpBy.Text == string.Empty && txtAmt.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtExpName, "Enter all details.");
                    txtExpName.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter all details.";
                }
                else if (txtExpName.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtExpName, "Enter Expense-name");
                    txtExpName.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter Customer-name.";
                }
                else if (txtExpBy.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtExpBy, "Enter Expense By.");
                    txtExpBy.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter Expense By.";
                }
                else if (txtAmt.Text == string.Empty)
                {
                    errorProvider1.Clear();
                    errorProvider1.SetError(txtAmt, "Enter Amount.");
                    txtAmt.Focus();
                    panel3.Visible = true;
                    lblError.Text  = "Enter Amount.";
                }
                else
                {
                    //DateTime date = DateTime.ParseExact(dateToday.Text, "yyyy-MM-dd", null);
                    if (btnCreate.Text == "Save")
                    {
                        tblExpens data = new tblExpens();

                        data.expName = txtExpName.Text.Trim().ToString();
                        data.expBy   = txtExpBy.Text.Trim().ToString();
                        data.expDate = dtpExpDate.Value.Date;
                        data.amount  = Convert.ToDecimal(txtAmt.Text);
                        data.cdate   = DateTime.Now;

                        _entities.tblExpenses.Add(data);
                        _entities.SaveChanges();
                        MessageBox.Show("Record Created Successfully");
                    }
                    else
                    {
                        //Update Code

                        _entities = new KBBQEntities();
                        //var pId = _entities.purchaseProducts.Where(x => x.pName == txtitemName.Text.Trim()).FirstOrDefault().id;


                        var expData = _entities.tblExpenses.Where(x => x.id == passedId).FirstOrDefault();

                        expData.expName = txtExpName.Text.Trim().ToString();
                        expData.expBy   = txtExpBy.Text.Trim().ToString();
                        expData.expDate = dtpExpDate.Value.Date;
                        expData.amount  = Convert.ToDecimal(txtAmt.Text);
                        expData.udate   = DateTime.Now;

                        _entities.SaveChanges();

                        Clear();
                        MessageBox.Show("Record Updated Successfully");
                    }

                    dataGridViewBind();
                }
            }
            catch (Exception x)
            {
            }
        }