Ejemplo n.º 1
0
    private static void LoadCatagoryModels()
    {
        if (Managers.Data.FileData.CatagoryModels.Count == 0)
        {
            CatagoryModel Catagory1 = new CatagoryModel();
            Catagory1.ColorCode = "e06c75";
            Catagory1.NameText  = "Roth IRA";
            Catagory1.Recurring = true;
            Catagory1.Save();

            CatagoryModel Catagory2 = new CatagoryModel();
            Catagory2.ColorCode = "61afef";
            Catagory2.NameText  = "Restaurant";
            Catagory2.Recurring = false;
            Catagory2.Save();

            CatagoryModel Catagory3 = new CatagoryModel();
            Catagory3.ColorCode = "ffb86c";
            Catagory3.NameText  = "Mortgage";
            Catagory3.Recurring = true;
            Catagory3.Save();

            CatagoryModel Catagory4 = new CatagoryModel();
            Catagory4.ColorCode = "acce1b";
            Catagory4.NameText  = "Miscellaneous";
            Catagory4.Recurring = false;
            Catagory4.Save();


            CatagoryModel Catagory5 = new CatagoryModel();
            Catagory5.ColorCode = "c678dd";
            Catagory5.NameText  = "HOA";
            Catagory5.Recurring = true;
            Catagory5.Save();

            CatagoryModel Catagory6 = new CatagoryModel();
            Catagory6.ColorCode = "94B57C";
            Catagory6.NameText  = "Groceries";
            Catagory6.Recurring = false;
            Catagory6.Save();

            CatagoryModel Catagory7 = new CatagoryModel();
            Catagory7.ColorCode = "d19a66";
            Catagory7.NameText  = "Gas";
            Catagory7.Recurring = false;
            Catagory7.Save();

            CatagoryModel Catagory8 = new CatagoryModel();
            Catagory8.ColorCode = "60B9BD";
            Catagory8.NameText  = "Entertainment";
            Catagory8.Recurring = false;
            Catagory8.Save();

            CatagoryModel Catagory9 = new CatagoryModel();
            Catagory9.ColorCode = "FF79C6";
            Catagory9.NameText  = "Extra Mortgage";
            Catagory9.Recurring = true;
            Catagory9.Save();
        }
    }
Ejemplo n.º 2
0
 private void catagorySaveButton_Click(object sender, EventArgs e)
 {
     if (!Ch.IsMatch(catagoryTextBox.Text.Trim()))
     {
         cMessageBox.Warning("Invaild Input Detected");
     }
     else
     {
         CatagoryModel catagoryModel = new CatagoryModel();
         catagoryModel.Name = catagoryTextBox.Text.Trim();
         SetupGateway catagoryGateway = new SetupGateway();
         bool         isExist         = catagoryGateway.IsExists(catagoryModel);
         if (isExist == true)
         {
             cMessageBox.Information("Category Already Exist");
         }
         else
         {
             int rowAffect = catagoryGateway.SaveCatagory(catagoryModel);
             if (rowAffect > 0)
             {
                 cMessageBox.Success("Category Successfully Saved");
                 CatagorySetup_Load(sender, e);
             }
             else
             {
                 cMessageBox.Failed("Failed To Save Category, Try Again");
                 CatagorySetup_Load(sender, e);
             }
         }
     }
 }
Ejemplo n.º 3
0
 public void UpdateView(CatagoryModel model, decimal catagoryTotal)
 {
     NameTextMesh.text = model.NameText;
     SetColor(model.ColorCode);
     TotalTextMesh.text = "$" + catagoryTotal.ToString();
     SetAction(Controller.Instance.PushCatagoryWindow, model.CatagoryID);
 }
Ejemplo n.º 4
0
        private void CatagoryUpdateButton_Click(object sender, EventArgs e)
        {
            SetupGateway setupGateway = new SetupGateway();

            if (idhiddenLabel.Text.Trim() != String.Empty && Ch.IsMatch(catagoryTextBox.Text.Trim()))
            {
                CatagoryModel catagory = new CatagoryModel();
                catagory.Name = catagoryTextBox.Text.Trim();
                catagory.Id   = Convert.ToInt32(idhiddenLabel.Text);
                bool isExist = setupGateway.IsExists(catagory);
                if (isExist == true)
                {
                    cMessageBox.Information("Category Already Exist");
                }
                else
                {
                    int rowAffect = setupGateway.UpdateCatagory(catagory);
                    if (rowAffect > 0)
                    {
                        cMessageBox.Success("Category Updated");
                        CatagorySetup_Load(sender, e);
                    }
                    else
                    {
                        cMessageBox.Failed("Faild to Updated Category");
                        CatagorySetup_Load(sender, e);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private CatagoryElement ConstructCatagoryElement(CatagoryModel model, decimal total, int index)
        {
            CatagoryElement newExpense = GameObject.Instantiate(original: CatagoryElements[index - 1], parent: CatagoryElements[index - 1].transform.parent.transform) as CatagoryElement;
            RectTransform   newRect    = newExpense.GetComponent <RectTransform>();

            newRect.anchoredPosition = new Vector3(newRect.anchoredPosition.x, newRect.anchoredPosition.y - CatagoryOffset);
            //newExpense.SetTileRect(TileRect); Add Later if I want the catagory tiles to scroll.
            newExpense.UpdateView(model, total);
            return(newExpense);
        }
Ejemplo n.º 6
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     catagory = (CatagoryModel)this.FindResource("cat");
     POS_Catagory();
     fly.DataContext    = _itemViewModel;
     flyout.DataContext = newcatagory;
     webHandler.POS_add_catagoryCompleted += async(x, y) =>
     {
         if (y.Result == 1)
         {
             var win = (MetroWindow)Application.Current.MainWindow;
             var res = await win.ShowMessageAsync("New catagory added", "new catagory was succefully added",
                                                  MessageDialogStyle.Affirmative);
         }
         else
         {
             var win = (MetroWindow)Application.Current.MainWindow;
             var res = await win.ShowMessageAsync("Something went wrong", "try again in a little bit",
                                                  MessageDialogStyle.Affirmative);
         }
     };
     webHandler.POS_update_catagoryCompleted += async(x, y) =>
     {
         if (y.Result == 1)
         {
             var win = (MetroWindow)Application.Current.MainWindow;
             var res = await win.ShowMessageAsync("Catagory changes saved", "",
                                                  MessageDialogStyle.Affirmative);
         }
         else
         {
             var win = (MetroWindow)Application.Current.MainWindow;
             var res = await win.ShowMessageAsync("Something went wrong", "try again in a little bit",
                                                  MessageDialogStyle.Affirmative);
         }
     };
     webHandler.POS_delete_catagoryCompleted += async(x, y) =>
     {
         if (y.Result == 1)
         {
             var win = (MetroWindow)Application.Current.MainWindow;
             var res = await win.ShowMessageAsync("Catgory removed", "The Catgory was removed",
                                                  MessageDialogStyle.Affirmative);
         }
         else
         {
             var win = (MetroWindow)Application.Current.MainWindow;
             var res = await win.ShowMessageAsync("Something went wrong", "try again in a little bit",
                                                  MessageDialogStyle.Affirmative);
         }
     };
 }
        public bool IsExists(CatagoryModel catagory)
        {
            string query = "SELECT * FROM Catagories WHERE Name=@catagory";

            Command = new SqlCommand(query, Connection);
            Command.Parameters.AddWithValue("@catagory", catagory.Name);
            Connection.Open();
            Reader = Command.ExecuteReader();
            bool isExists = Reader.HasRows;

            Connection.Close();
            return(isExists);
        }
Ejemplo n.º 8
0
        public int Update(CatagoryModel catagoryRelator)
        {
            string query = "Update catagoris SET catagory = @catagory WHERE Id = @id";

            command = new SqlCommand(query, connection);
            command.Parameters.AddWithValue("@catagory", catagoryRelator.Catagory);
            command.Parameters.AddWithValue("@Id", catagoryRelator.Id);
            connection.Open();
            int rowAffect = command.ExecuteNonQuery();

            connection.Close();
            return(rowAffect);
        }
Ejemplo n.º 9
0
        private CatagoryModel[] GetFilteredCatagoryModels(List <CatagoryModel> catagoryModels)
        {
            CatagoryModel[] newCatagoryModels = new CatagoryModel[MatchedIsRecurringCount(catagoryModels)];
            int             count             = 0;

            for (int index = 0; index < catagoryModels.Count; index++)
            {
                if (catagoryModels[index].Recurring == IsRecurring)
                {
                    newCatagoryModels[count++] = catagoryModels[index];
                }
            }
            return(newCatagoryModels);
        }
Ejemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int Id = Convert.ToInt32(Request.QueryString["Id"]);
                //Response.Write(Id);
                CatagoryModel catagoryRelator = catagoryManager.GetCatagoryByID(Id);

                if (catagoryRelator != null)
                {
                    hiddenFieldID.Value  = Convert.ToString(catagoryRelator.Id);
                    catagotyTextBox.Text = catagoryRelator.Catagory;
                    hiddenFieldID.Value  = catagoryRelator.Id.ToString();
                }
            }
        }
Ejemplo n.º 11
0
 public void Save()
 {
     if (CatagoryID == -1)
     {
         CatagoryID = IDTracker.CreateNew(IDType.CATAGORY);
         IDTracker.SaveID(IDType.CATAGORY, CatagoryID);
     }
     else
     {
         CatagoryModel modelToDelete = UI.DataQueries.GetCatagoryModel(Managers.Data.FileData.CatagoryModels, CatagoryID);
         Managers.Data.FileData.CatagoryModels.Remove(modelToDelete);
     }
     Managers.Data.FileData.CatagoryModels.Add(this);
     Managers.Data.Save();
     //Messenger.Broadcast(AppEvent.CATAGORIES_UPDATED);
 }
Ejemplo n.º 12
0
        public int save(CatagoryModel catagoryRelator)
        {
            string query = "Insert Into catagoris(catagory) values(@catagory)";

            command = new SqlCommand(query, connection);
            command.Parameters.AddWithValue("@catagory", catagoryRelator.Catagory);

            connection.Open();

            int rowAffect = command.ExecuteNonQuery();

            connection.Close();


            return(rowAffect);
        }
 public int SaveCatagory(CatagoryModel catagory)
 {
     try
     {
         Connection.Open();
         string query = "Insert Into Catagories(Name) values(@name)";
         Command = new SqlCommand(query, Connection);
         Command.Parameters.AddWithValue("@name", catagory.Name);
         int rowAffect = Command.ExecuteNonQuery();
         Connection.Close();
         return(rowAffect);
     }
     catch (Exception)
     {
         return(0);
     }
 }
Ejemplo n.º 14
0
        protected void catagroySavebutton_Click(object sender, EventArgs e)
        {
            if (catagotyTextBox.Text.Trim() == "")
            {
                outputlabel.InnerHtml = "Please Provide a vailed Catagory";
            }
            else
            {
                CatagoryModel catagoryRelator = new CatagoryModel();

                catagoryRelator.Catagory = catagotyTextBox.Text;
                string message = CatagoryManager.catagorySave(catagoryRelator);
                outputlabel.InnerHtml          = message;
                CatagoryListGridVew.DataSource = CatagoryManager.GetAllCatagory();
                CatagoryListGridVew.DataBind();
            }
        }
 public int UpdateCatagory(CatagoryModel catagoryModel)
 {
     try
     {
         string query = "Update Catagories SET Name = @name WHERE  Id= @id";
         Command = new SqlCommand(query, Connection);
         Command.Parameters.AddWithValue("@name", catagoryModel.Name);
         Command.Parameters.AddWithValue("@id", catagoryModel.Id);
         Connection.Open();
         int rowAffect = Command.ExecuteNonQuery();
         Connection.Close();
         return(rowAffect);
     }
     catch (Exception)
     {
         return(0);
     }
 }
 public string catagoryUpdate(CatagoryModel catagoryRelator)
 {
     if (catagoryGateway.IsExists(catagoryRelator.Catagory))
     {
         return("* Catagroy Name Alredy Exist Try Different Name");
     }
     else
     {
         int rowAffect = catagoryGateway.Update(catagoryRelator);
         if (rowAffect > 0)
         {
             return("Catagory Update Seccesfull");
         }
         else
         {
             return("*Catagory Does Not Updated");
         }
     }
 }
 public string catagorySave(CatagoryModel catagoryRelator)
 {
     if (catagoryGateway.IsExists(catagoryRelator.Catagory))
     {
         return("* Catagroy Name Alredy Exist");
     }
     else
     {
         int rowAffect = catagoryGateway.save(catagoryRelator);
         if (rowAffect > 0)
         {
             return("Catagory setup Seccesfull");
         }
         else
         {
             return("*Data Not Saved Try Again");
         }
     }
 }
Ejemplo n.º 18
0
 protected void catagroyUpdateButton_Click(object sender, EventArgs e)
 {
     if (catagotyTextBox.Text.Trim() == "")
     {
         outputlabel.InnerHtml = "Please Provide a vailed Catagory";
     }
     else
     {
         CatagoryModel catagoryRelator = new CatagoryModel();
         catagoryRelator.Id       = Convert.ToInt32(hiddenFieldID.Value);
         catagoryRelator.Catagory = catagotyTextBox.Text;
         string message = catagoryManager.catagoryUpdate(catagoryRelator);
         outputlabel.InnerHtml = message;
         if (outputlabel.InnerHtml.Contains("Catagory Update Seccesfull"))
         {
             Response.Redirect("CatagoryUI.aspx");
         }
     }
 }
        public List <CatagoryModel> GetAllCatagory()
        {
            List <CatagoryModel> catagoryList = new List <CatagoryModel>();
            String query = "SELECT*FROM Catagories WHERE Active =1";

            Command = new SqlCommand(query, Connection);
            Connection.Open();
            Reader = Command.ExecuteReader();
            while (Reader.Read())
            {
                CatagoryModel catagroy = new CatagoryModel();
                catagroy.Id   = Convert.ToInt32(Reader["Id"]);
                catagroy.Name = Reader["Name"].ToString();
                catagoryList.Add(catagroy);
            }
            Reader.Close();
            Connection.Close();
            return(catagoryList);
        }
Ejemplo n.º 20
0
        public List <CatagoryModel> GetAllCatagory()
        {
            List <CatagoryModel> catagoryList = new List <CatagoryModel>();
            String query = "SELECT*FROM Catagoris";

            command = new SqlCommand(query, connection);
            connection.Open();
            reader = command.ExecuteReader();
            while (reader.Read())
            {
                CatagoryModel CatagoryRelator = new CatagoryModel();
                CatagoryRelator.Id       = Convert.ToInt32(reader["Id"]);
                CatagoryRelator.Catagory = reader["Catagory"].ToString();
                catagoryList.Add(CatagoryRelator);
            }
            reader.Close();
            connection.Close();
            return(catagoryList);
        }
Ejemplo n.º 21
0
 private async void catagorytList_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         selected = (CatagoryModel)catagoryList.SelectedItem;
         if (selected != null)
         {
             del.IsEnabled = true;
         }
     }
     catch (Exception)
     {
         del.IsEnabled     = false;
         update.Foreground = Brushes.Gray;
         del.Foreground    = Brushes.Gray;
         var win = (MetroWindow)Application.Current.MainWindow;
         var res = await win.ShowMessageAsync("Something went wrong", "Try again in a little bit",
                                              MessageDialogStyle.AffirmativeAndNegative);
     }
 }
Ejemplo n.º 22
0
        public HttpResponseMessage CatagoryAdd(CatagoryModel _CatagoryModel)
        {
            try
            {
                bool conn = false;
                conn = db.Database.Exists();
                if (!conn)
                {
                    ConnectionTools.changeToLocalDB(db);
                    conn = db.Database.Exists();
                }

                if (conn)
                {
                    TBL_CATAGORY cat = new TBL_CATAGORY();
                    cat.BAR_CODE_PREFIX = _CatagoryModel.BAR_CODE_PREFIX;
                    cat.CATAGORY_DEC    = _CatagoryModel.CATAGORY_DEC;
                    cat.CATAGORY_NAME   = _CatagoryModel.CATAGORY_NAME;
                    cat.COMPANY_ID      = _CatagoryModel.COMPANY_ID;
                    cat.DISPLAY_INDEX   = _CatagoryModel.DISPLAY_INDEX;
                    cat.IS_DELETE       = false;
                    cat.IS_NOT_PROTAL   = _CatagoryModel.IS_NOT_PROTAL;
                    db.TBL_CATAGORY.Add(cat);
                    db.SaveChanges();
                    return(Request.CreateResponse(HttpStatusCode.OK, "success"));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.ExpectationFailed));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                ConnectionTools.ChangeToRemoteDB(db);
            }
        }
Ejemplo n.º 23
0
        public HttpResponseMessage CatagoryUpdate(CatagoryModel _CatagoryModel)
        {
            try
            {
                bool conn = false;
                conn = db.Database.Exists();
                if (!conn)
                {
                    ConnectionTools.changeToLocalDB(db);
                    conn = db.Database.Exists();
                }

                if (conn)
                {
                    var str = (from a in db.TBL_CATAGORY where a.CATAGORY_ID == _CatagoryModel.CATAGORY_ID select a).FirstOrDefault();
                    str.BAR_CODE_PREFIX = _CatagoryModel.BAR_CODE_PREFIX;
                    str.CATAGORY_DEC    = _CatagoryModel.CATAGORY_DEC;
                    str.CATAGORY_NAME   = _CatagoryModel.CATAGORY_NAME;
                    str.COMPANY_ID      = _CatagoryModel.COMPANY_ID;
                    str.DISPLAY_INDEX   = _CatagoryModel.DISPLAY_INDEX;
                    str.IS_DELETE       = false;
                    str.IS_NOT_PROTAL   = _CatagoryModel.IS_NOT_PROTAL;
                    db.SaveChanges();
                    return(Request.CreateResponse(HttpStatusCode.OK, "success"));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.ExpectationFailed));
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                ConnectionTools.ChangeToRemoteDB(db);
            }
        }
Ejemplo n.º 24
0
        public CatagoryModel GetCatagoryByID(int Id)
        {
            String query = "SELECT*FROM Catagoris WHERE Id = @Id";

            command = new SqlCommand(query, connection);
            command.Parameters.AddWithValue("@Id", Id);
            connection.Open();
            reader = command.ExecuteReader();
            reader.Read();
            CatagoryModel CatagoryRelator = null;

            if (reader.HasRows)
            {
                CatagoryRelator          = new CatagoryModel();
                CatagoryRelator.Id       = Convert.ToInt32(reader["Id"]);
                CatagoryRelator.Catagory = reader["Catagory"].ToString();
            }

            reader.Close();
            connection.Close();
            return(CatagoryRelator);
        }
Ejemplo n.º 25
0
 public void UpdateView(CatagoryModel Model, float width)
 {
     BarRect.sizeDelta   = new Vector2(width, BarRect.sizeDelta.y);
     ColorBarImage.color = ColorConverter.HexToColor(Model.ColorCode);
 }