Example #1
0
 public bool Update(tInvoice entity)
 {
     if (entity == null)
     {
         return(false);
     }
     context.Invoices.Update(entity);
     context.SaveChanges();
     return(true);
 }
Example #2
0
 public bool Insert(tInvoice entity)
 {
     if (entity == null)
     {
         return(false);
     }
     context.Invoices.Add(entity);
     context.SaveChanges();
     return(true);
 }
Example #3
0
 public bool Save(tInvoice entity)
 {
     // hard coded value for possibility of authoriazation module
     entity.Customer = null;
     entity.UserId   = 1;
     if (entity.Id > 0)
     {
         return(invoiceRepo.Update(entity));
     }
     return(invoiceRepo.Insert(entity));
 }
Example #4
0
        public bool Delete(int id)
        {
            if (id <= 0)
            {
                return(false);
            }

            tInvoice entity = context.Invoices.SingleOrDefault(s => s.Id == id);

            if (entity != null)
            {
                context.Remove(entity);
                context.SaveChanges();
                return(true);
            }
            return(false);
        }
Example #5
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (ValidateInvoice())
         {
             DateTime dtPaid = DateTime.Now;
             DateTime dtDate = DateTime.Now;
             if (txtDate.Text.Length > 0)
             {
                 DateTime.TryParse(txtDate.Text, out dtDate);
             }
             if (txtPaid.Text.Length > 0)
             {
                 DateTime.TryParse(txtPaid.Text, out dtPaid);
                 tInvoice invoice = new tInvoice
                 {
                     InvoiceAmount = GetDecimal(txtAmount.Text),
                     InvoiceDate = dtDate,
                     InvoiceNo = txtInvoice.Text.Trim(),
                     InvoicePaidDate = dtPaid,
                     InvoicePurchaseId = m_nPurchaseId,
                 };
                 m_db.tInvoices.InsertOnSubmit(invoice);
             }
             else
             {
                 tInvoice invoice = new tInvoice
                 {
                     InvoiceAmount = GetDecimal(txtAmount.Text),
                     InvoiceDate = dtDate,
                     InvoiceNo = txtInvoice.Text.Trim(),
                     InvoicePurchaseId = m_nPurchaseId,
                 };
                 m_db.tInvoices.InsertOnSubmit(invoice);
             }
             m_db.SubmitChanges();
             gridInvoices.DataBind();
             lblError.Text = "";
         }
     }
     catch (Exception ex)
     {
         lblError.Text = ex.Message;
     }
 }
Example #6
0
 public bool SaveInvoice(tInvoice invoice)
 {
     return(invoiceService.Save(invoice));
 }