Beispiel #1
0
        async Task SaveVitalsAsync()
        {
            //if (IsBusy || !(await LoginAsync()))
            //    return;
            try
            {
                if (IsBusy)
                {
                    return;
                }
                IsBusy = true;
                var vVitalDetails = new ExpenseMaster()
                {
                    UsrEmail  = "*****@*****.**",
                    DateTaken = DateTime.Today,
                    Price     = Convert.ToDecimal(dblPrice),
                    Quantity  = Convert.ToDecimal(dblBmi),
                    Total     = Convert.ToDecimal(dblTotal)
                };
                await azureService.AddVitals(vVitalDetails);

                await App.Current.MainPage.Navigation.PopAsync();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("OH NO!" + ex);
                await Application.Current.MainPage.DisplayAlert("Sync Error", "Unable to sync coffees, you may be offline", "OK");
            }
            finally
            {
                IsBusy = false;
            }
        }
        public Int64 Update(ExpenseMaster objcategory)
        {
            Int64 result = 0;

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "Expense_Update";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;

                SqlParameter param = new SqlParameter();
                param.ParameterName = "@eid";
                param.Value         = objcategory.eid;
                param.SqlDbType     = SqlDbType.BigInt;
                param.Direction     = ParameterDirection.InputOutput;
                cmd.Parameters.Add(param);
                cmd.Parameters.AddWithValue("@Expensename", objcategory.Expensename);

                ConnectionString.Open();
                cmd.ExecuteNonQuery();
                result = Convert.ToInt64(param.Value);
            }
            catch (Exception ex)
            {
                //ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(result);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(result);
        }
    public void BindExpenes(Int64 CategoryId)
    {
        ExpenseMaster objcategory = (new Cls_ExpenseMaster_b().SelectById(CategoryId));

        if (objcategory != null)
        {
            txtExpenseName.Text = objcategory.Expensename;
        }
    }
Beispiel #4
0
        public async Task <bool> AddVitals(ExpenseMaster aExpenseMaster)
        {
            await Initialize();

            await mExpenseMasterTable.InsertAsync(aExpenseMaster);

            await SyncVitals();

            //return coffee
            return(true);
        }
 public bool UpdateExpense(ExpenseMaster expense)
 {
     using (var _context = new AdminPortalEntities())
     {
         _context.ExpenseMasters.Attach(expense);
         _context.Entry(expense).State = EntityState.Modified;
         foreach (ExpenseSummary s in expense.ExpenseSummaries)
         {
             _context.ExpenseSummaries.Attach(s);
             _context.Entry(s).State = EntityState.Modified;
         }
         _context.SaveChanges();
         return(true);
     }
 }
 public bool CreateExpense(ExpenseMaster expense)
 {
     using (var _context = new AdminPortalEntities())
     {
         _context.ExpenseMasters.Add(expense);
         _context.SaveChanges();
         expense.ExpenseCode = "Ex" + (1100 + expense.ExpenseId).ToString();
         _context.ExpenseMasters.Attach(expense);
         _context.Entry(expense).State = EntityState.Modified;
         _context.SaveChanges();
         //_context.ExpenseSummaries.AddRange(expense.ExpenseSummaries);
         //_context.SaveChanges();
         return(true);
     }
 }
        public ExpenseMaster SelectById(Int64 id)
        {
            SqlDataAdapter da;
            DataSet        ds          = new DataSet();
            ExpenseMaster  objcategory = new ExpenseMaster();

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "Expense_SelectById";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;
                cmd.Parameters.AddWithValue("@eid", id);
                ConnectionString.Open();
                da = new SqlDataAdapter(cmd);
                da.Fill(ds);

                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0] != null)
                        {
                            if (ds.Tables[0].Rows.Count > 0)
                            {
                                {
                                    objcategory.eid         = Convert.ToInt64(ds.Tables[0].Rows[0]["eid"]);
                                    objcategory.Expensename = Convert.ToString(ds.Tables[0].Rows[0]["Expensename"]);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //  ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(null);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(objcategory);
        }
        public ExpenseMaster GetExpenseForRepoManager(int id, string userId = null)
        {
            using (var _context = new AdminPortalEntities())
            {
                ExpenseMaster expense = new ExpenseMaster();

                if (userId != null)
                {
                    expense = _context.ExpenseMasters.Where(x => x.ExpenseId == id && x.AspNetUser.AspNetUser1.Id == userId && x.IsDeleted == false).Include(x => x.AspNetUser).Include(x => x.AspNetUser.AspNetUser1).Include(x => x.LookupCodeMaster).FirstOrDefault();
                }
                else
                {
                    expense = _context.ExpenseMasters.Where(x => x.ExpenseId == id && x.IsDeleted == false).Include(x => x.AspNetUser).Include(x => x.AspNetUser.AspNetUser1).Include(x => x.LookupCodeMaster).FirstOrDefault();
                }

                return(expense);
            }
        }
        public ExpenseMaster GetJustMyExpense(int id, string userId = null)
        {
            using (var _context = new AdminPortalEntities())
            {
                ExpenseMaster expense = new ExpenseMaster();

                if (userId != null)
                {
                    expense = _context.ExpenseMasters.Where(x => x.ExpenseId == id && x.UserId == userId && x.IsDeleted == false).FirstOrDefault();
                }
                else
                {
                    expense = _context.ExpenseMasters.Where(x => x.ExpenseId == id && x.IsDeleted == false).FirstOrDefault();
                }

                return(expense);
            }
        }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Int64         Result      = 0;
        ExpenseMaster objcategory = new ExpenseMaster();

        objcategory.Expensename = txtExpenseName.Text.Trim();

        if (Request.QueryString["id"] != null)
        {
            objcategory.eid = Convert.ToInt64(ocommon.Decrypt(Request.QueryString["id"].ToString(), true));
            Result          = (new Cls_ExpenseMaster_b().Update(objcategory));
            if (Result > 0)
            {
                Clear();
                Response.Redirect(Page.ResolveUrl("~/Manage_expenseMaster.aspx?mode=u"));
            }
            else
            {
                Clear();
                spnMessgae.Style.Add("color", "red");
                spnMessgae.InnerText = "Expense Not Updated";
                BindExpenes(Convert.ToInt64(ocommon.Decrypt(Request.QueryString["id"].ToString(), true)));
            }
        }
        else
        {
            Result = (new Cls_ExpenseMaster_b().Insert(objcategory));
            if (Result > 0)
            {
                Clear();
                Response.Redirect(Page.ResolveUrl("~/Manage_expenseMaster.aspx?mode=i"));
            }
            else
            {
                Clear();
                spnMessgae.Style.Add("color", "red");
                spnMessgae.InnerText = "Expense Not Inserted";
            }
        }
    }