Пример #1
0
    public NewMenu WeeklyMenu(string userId, string menuId)
    {
        NewMenu x = new NewMenu();

        db.AddColumn(userId, db.GetDataBasePath(userId, userDataBase), db.menues, MENU_DATA, "TEXT"); //new column in menues tbl.
        db.AddColumn(userId, db.GetDataBasePath(userId, userDataBase), db.menues, MY_MEALS, "TEXT");  //new column in menues tbl.
        try {
            if (!string.IsNullOrEmpty(menuId))
            {
                using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + db.GetDataBasePath(userId, userDataBase))) {
                    connection.Open();
                    string sql = string.Format(@"SELECT id, title, diet, date, note, userId, clientId, userGroupId, energy, menuData, myMeals FROM menues WHERE id = '{0}'", menuId);
                    using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
                        Clients.Client client = new Clients.Client();
                        using (SQLiteDataReader reader = command.ExecuteReader()) {
                            while (reader.Read())
                            {
                                x = GetData(reader, userId);
                            }
                        }
                    }
                }
            }
            return(x);
        } catch (Exception e) {
            L.SendErrorLog(e, menuId, userId, "Menues", "WeeklyMenu");
            return(x);
        }
    }
Пример #2
0
 public string Get(string userId, string id)
 {
     try {
         SQLiteConnection connection = new SQLiteConnection("Data Source=" + db.GetDataBasePath(userId, dataBase));
         connection.Open();
         string        sql     = @"SELECT id, title, description, energy, mealGroup
                     FROM recipes
                     WHERE id = @id";
         SQLiteCommand command = new SQLiteCommand(sql, connection);
         command.Parameters.Add(new SQLiteParameter("id", id));
         NewRecipe        x      = new NewRecipe();
         Clients.Client   client = new Clients.Client();
         SQLiteDataReader reader = command.ExecuteReader();
         while (reader.Read())
         {
             x.id          = reader.GetValue(0) == DBNull.Value ? "" : reader.GetString(0);
             x.title       = reader.GetValue(1) == DBNull.Value ? "" : reader.GetString(1);
             x.description = reader.GetValue(2) == DBNull.Value ? "" : reader.GetString(2);
             x.energy      = reader.GetValue(3) == DBNull.Value ? 0 : Convert.ToDouble(reader.GetString(3));
             x.mealGroup   = reader.GetValue(4) == DBNull.Value ? "" : reader.GetString(4);
             x.data        = JsonConvert.DeserializeObject <JsonFile>(GetJsonFile(userId, x.id));
             x.mealGroups  = InitMealGroups();
         }
         connection.Close();
         return(JsonConvert.SerializeObject(x, Formatting.None));
     } catch (Exception e) { return(e.Message); }
 }
Пример #3
0
    public string GetClientMenusCount(string userId, string clientId)
    {
        int x = 0;

        try {
            using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + db.GetDataBasePath(userId, userDataBase))) {
                connection.Open();
                string sql = string.Format(@"
                        SELECT COUNT(id) FROM menues WHERE userId = '{0}' AND clientId = '{1}'", userId, clientId);
                using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
                    Clients.Client client = new Clients.Client();
                    using (SQLiteDataReader reader = command.ExecuteReader()) {
                        while (reader.Read())
                        {
                            x = reader.GetValue(0) == DBNull.Value ? 0 : reader.GetInt32(0);
                        }
                    }
                }
            }
            return(JsonConvert.SerializeObject(x, Formatting.None));
        } catch (Exception e) {
            L.SendErrorLog(e, null, userId, "Menus", "GetClientMenusCount");
            return(JsonConvert.SerializeObject(e.Message, Formatting.None));
        }
    }
Пример #4
0
 public string LoadClientMenues(string userId, string clientId)
 {
     try {
         List <NewMenu> xx = new List <NewMenu>();
         using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + db.GetDataBasePath(userId, dataBase))) {
             connection.Open();
             string sql = string.Format(@"
                     SELECT id, title, diet, date, note, userId, clientId, userGroupId, energy
                     FROM menues WHERE userId = '{0}' AND clientId = '{1}'
                     ORDER BY rowid DESC", userId, clientId);
             using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
                 Clients.Client client = new Clients.Client();
                 using (SQLiteDataReader reader = command.ExecuteReader()) {
                     while (reader.Read())
                     {
                         NewMenu x = new NewMenu();
                         x.id          = reader.GetValue(0) == DBNull.Value ? "" : reader.GetString(0);
                         x.title       = reader.GetValue(1) == DBNull.Value ? "" : reader.GetString(1);
                         x.diet        = reader.GetValue(2) == DBNull.Value ? "" : reader.GetString(2);
                         x.date        = reader.GetValue(3) == DBNull.Value ? DateTime.UtcNow.ToString() : reader.GetString(3);
                         x.note        = reader.GetValue(4) == DBNull.Value ? "" : reader.GetString(4);
                         x.userId      = reader.GetValue(5) == DBNull.Value ? "" : reader.GetString(5);
                         x.client      = (reader.GetValue(6) == DBNull.Value || reader.GetValue(7) == DBNull.Value) ? new Clients.NewClient() : client.GetClient(reader.GetString(7), reader.GetString(6));
                         x.userGroupId = reader.GetValue(7) == DBNull.Value ? "" : reader.GetString(7);
                         x.energy      = reader.GetValue(8) == DBNull.Value ? 0 : Convert.ToDouble(reader.GetString(8));
                         xx.Add(x);
                     }
                 }
             }
             connection.Close();
         }
         return(JsonConvert.SerializeObject(xx, Formatting.None));
     } catch (Exception e) { return(e.Message); }
 }
Пример #5
0
 public string Get(string userId, string id)
 {
     try {
         NewRecipe x = new NewRecipe();
         //db.CreateDataBase(userId, db.recipes);
         //db.AddColumn(userId, db.GetDataBasePath(userId, dataBase), db.recipes, MEAL_GROUP);  //new column in recipes tbl.
         //db.AddColumn(userId, db.GetDataBasePath(userId, dataBase), db.recipes, RECIPE_DATA, "TEXT");  //new column in recipes tbl.
         //db.AddColumn(userId, db.GetDataBasePath(userId, dataBase), db.recipes, CONSUMERS, "INTEGER");  //new column in recipes tbl.
         //db.AddColumn(userId, db.GetDataBasePath(userId, dataBase), db.recipes, USER_ID, "VARCHAR(50)");  //new column in recipes tbl.
         using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + db.GetDataBasePath(userId, dataBase))) {
             connection.Open();
             string sql = @"SELECT id, title, description, energy, mealGroup, recipeData, consumers, userId FROM recipes WHERE id = @Id";
             using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
                 command.Parameters.Add(new SQLiteParameter("Id", id));
                 Clients.Client client = new Clients.Client();
                 using (SQLiteDataReader reader = command.ExecuteReader()) {
                     while (reader.Read())
                     {
                         x = GetData(reader, userId, true);
                     }
                 }
             }
         }
         return(JsonConvert.SerializeObject(x, Formatting.None));
     } catch (Exception e) {
         L.SendErrorLog(e, id, null, "Recipes", "Get");
         return(JsonConvert.SerializeObject(e.Message, Formatting.None));
     }
 }
Пример #6
0
 public string GetAppRecipe(string id, string lang)
 {
     try {
         NewRecipe x = new NewRecipe();
         using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + Server.MapPath(string.Format("~/App_Data/{0}", appDataBase)))) {
             connection.Open();
             string sql = string.Format(@"SELECT id, title, description, energy FROM recipes WHERE id = '{0}'", id);
             using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
                 Clients.Client client = new Clients.Client();
                 using (SQLiteDataReader reader = command.ExecuteReader()) {
                     while (reader.Read())
                     {
                         x.id          = reader.GetValue(0) == DBNull.Value ? "" : reader.GetString(0);
                         x.title       = reader.GetValue(1) == DBNull.Value ? "" : reader.GetString(1);
                         x.description = reader.GetValue(2) == DBNull.Value ? "" : reader.GetString(2);
                         x.energy      = reader.GetValue(3) == DBNull.Value ? 0 : Convert.ToDouble(reader.GetString(3));
                         x.data        = JsonConvert.DeserializeObject <JsonFile>(GetAppJsonFile(x.id, lang));
                     }
                 }
             }
             connection.Close();
         }
         return(JsonConvert.SerializeObject(x, Formatting.None));
     } catch (Exception e) { return(e.Message); }
 }
Пример #7
0
 public string GetAppMenu(string id, string lang, bool toTranslate)
 {
     try {
         NewMenu x = new NewMenu();
         using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + Server.MapPath(string.Format("~/App_Data/{0}", appDataBase)))) {
             connection.Open();
             string sql = @"SELECT id, title, diet, note, energy
                     FROM menues
                     WHERE id = @id";
             using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
                 command.Parameters.Add(new SQLiteParameter("id", id));
                 Clients.Client client = new Clients.Client();
                 using (SQLiteDataReader reader = command.ExecuteReader()) {
                     while (reader.Read())
                     {
                         x.id     = reader.GetValue(0) == DBNull.Value ? "" : reader.GetString(0);
                         x.title  = reader.GetValue(1) == DBNull.Value ? "" : reader.GetString(1);
                         x.diet   = reader.GetValue(2) == DBNull.Value ? "" : reader.GetString(2);
                         x.note   = reader.GetValue(3) == DBNull.Value ? "" : reader.GetString(3);
                         x.energy = reader.GetValue(4) == DBNull.Value ? 0 : Convert.ToDouble(reader.GetString(4));
                         x.data   = JsonConvert.DeserializeObject <Data>(GetJsonFile(string.Format("~/App_Data/menues/{0}/{1}.json", lang, x.id)));
                     }
                 }
                 if (toTranslate == true)
                 {
                     x = TranslateManu(connection, x);
                 }
             }
             connection.Close();
         }
         return(JsonConvert.SerializeObject(x, Formatting.None));
     } catch (Exception e) { return(e.Message); }
 }
Пример #8
0
 public string Get(string userId, string id)
 {
     try {
         NewMenu x = new NewMenu();
         using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + db.GetDataBasePath(userId, dataBase))) {
             connection.Open();
             string sql = @"SELECT id, title, diet, date, note, userId, clientId, userGroupId, energy
                     FROM menues
                     WHERE id = @id";
             using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
                 command.Parameters.Add(new SQLiteParameter("id", id));
                 Clients.Client client = new Clients.Client();
                 using (SQLiteDataReader reader = command.ExecuteReader()) {
                     while (reader.Read())
                     {
                         x.id                        = reader.GetValue(0) == DBNull.Value ? "" : reader.GetString(0);
                         x.title                     = reader.GetValue(1) == DBNull.Value ? "" : reader.GetString(1);
                         x.diet                      = reader.GetValue(2) == DBNull.Value ? "" : reader.GetString(2);
                         x.date                      = reader.GetValue(3) == DBNull.Value ? DateTime.UtcNow.ToString() : reader.GetString(3);
                         x.note                      = reader.GetValue(4) == DBNull.Value ? "" : reader.GetString(4);
                         x.userId                    = reader.GetValue(5) == DBNull.Value ? "" : reader.GetString(5);
                         x.client                    = (reader.GetValue(6) == DBNull.Value || reader.GetValue(7) == DBNull.Value) ? new Clients.NewClient() : client.GetClient(reader.GetString(7), reader.GetString(6));
                         x.userGroupId               = reader.GetValue(7) == DBNull.Value ? "" : reader.GetString(7);
                         x.energy                    = reader.GetValue(8) == DBNull.Value ? 0 : Convert.ToDouble(reader.GetString(8));
                         x.data                      = JsonConvert.DeserializeObject <Data>(GetJsonFile(userId, x.id));
                         x.client.clientData         = new ClientsData.NewClientData();
                         x.client.clientData.myMeals = JsonConvert.DeserializeObject <MyMeals.NewMyMeals>(GetMyMealsJsonFile(userId, x.id));
                     }
                 }
             }
             connection.Close();
         }
         return(JsonConvert.SerializeObject(x, Formatting.None));
     } catch (Exception e) { return(e.Message); }
 }
Пример #9
0
 public NewMenu WeeklyMenu(string userId, string menuId)
 {
     try {
         NewMenu x = new NewMenu();
         if (!string.IsNullOrEmpty(menuId))
         {
             using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + db.GetDataBasePath(userId, dataBase))) {
                 connection.Open();
                 string sql = string.Format(@"SELECT id, title, diet, date, note, userId, clientId, userGroupId, energy
                     FROM menues
                     WHERE id = '{0}'", menuId);
                 using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
                     Clients.Client client = new Clients.Client();
                     using (SQLiteDataReader reader = command.ExecuteReader()) {
                         while (reader.Read())
                         {
                             x.id          = reader.GetValue(0) == DBNull.Value ? "" : reader.GetString(0);
                             x.title       = reader.GetValue(1) == DBNull.Value ? "" : reader.GetString(1);
                             x.diet        = reader.GetValue(2) == DBNull.Value ? "" : reader.GetString(2);
                             x.date        = reader.GetValue(3) == DBNull.Value ? DateTime.UtcNow.ToString() : reader.GetString(3);
                             x.note        = reader.GetValue(4) == DBNull.Value ? "" : reader.GetString(4);
                             x.userId      = reader.GetValue(5) == DBNull.Value ? "" : reader.GetString(5);
                             x.client      = reader.GetValue(6) == DBNull.Value ? new Clients.NewClient() : client.GetClient(x.userId, reader.GetString(6));
                             x.userGroupId = reader.GetValue(7) == DBNull.Value ? "" : reader.GetString(7);
                             x.energy      = reader.GetValue(8) == DBNull.Value ? 0 : Convert.ToDouble(reader.GetString(8));
                             x.data        = JsonConvert.DeserializeObject <Data>(GetJsonFile(userId, x.id));
                         }
                     }
                 }
                 connection.Close();
             }
         }
         return(x);
     } catch (Exception e) { return(new NewMenu()); }
 }
Пример #10
0
        public async Task <ActionResult> Stream(String id)
        {
            if (!String.IsNullOrEmpty(id))
            {
                ViewBag.Id = id;

                Models.ChainSettings setting = Global.Chains.SingleOrDefault(s => s.Name == id);
                using (Clients.Client client = new Clients.Client(setting.Host, setting.RPCUser, setting.RPCPassword, setting.Port))
                {
                    Models.ListStreams.Response response = await client.ListStreams(id);

                    List <ViewModels.StreamViewModel> streams = new List <ViewModels.StreamViewModel>();

                    foreach (Models.ListStreams.Result result in response.Result)
                    {
                        streams.Add(new ViewModels.StreamViewModel()
                        {
                            Chain = id, Name = result.Name, Open = result.Open, Subscribed = result.Subscribed, Synchronised = result.Synchronised
                        });
                    }
                    return(View(streams));
                }
            }
            else
            {
                throw new ArgumentNullException();
            }
        }
        public async Task <ActionResult> Index()
        {
            Models.ChainSettings setting = Global.Chains.SingleOrDefault(s => s.Name == id);
            using (Clients.Client client = new Clients.Client(setting.Host, setting.RPCUser, setting.RPCPassword, setting.Port))
            {
                ViewModels.StreamItemsViewModel viewModel = new ViewModels.StreamItemsViewModel();
                viewModel.ChainName = id;
                viewModel.Stream    = stream;

                List <Models.DTOs.Access> entities = new List <Models.DTOs.Access>();

                var response = await client.ListStreamItems(id, stream);

                if (response != null)
                {
                    foreach (Models.ListStreamsItems.Result result in response.Result)
                    {
                        //viewModel.Items.Add(result);
                        Models.DTOs.Access entity = Helpers.SerialisationHelper.ToObject <Models.DTOs.Access>(result.Data);
                        entities.Add(entity);
                    }
                }

                return(View(entities));
            }
        }
Пример #12
0
    public string Get(string id)
    {
        NewTicket x = new NewTicket();

        x.response = new Global.Response();
        try {
            if (!string.IsNullOrEmpty(id))
            {
                using (SQLiteConnection connection = new SQLiteConnection(string.Format("Data Source={0}", Server.MapPath(dataSource)))) {
                    connection.Open();
                    string sql = string.Format("SELECT {0} FROM recipes WHERE id = '{1}'", mainSql, id);
                    using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
                        Clients.Client client = new Clients.Client();
                        using (SQLiteDataReader reader = command.ExecuteReader()) {
                            while (reader.Read())
                            {
                                x = GetData(reader);
                            }
                        }
                    }
                }
            }
            x.response.isSuccess = true;
            x.response.msg       = "ok";
            return(JsonConvert.SerializeObject(x, Formatting.None));
        } catch (Exception e) {
            x.response.isSuccess = true;
            x.response.msg       = e.Message;
            L.SendErrorLog(e, id, null, "Tickets", "Get");
            return(JsonConvert.SerializeObject(x, Formatting.None));
        }
    }
Пример #13
0
 public string LoadAppMenues(string lang)
 {
     try {
         List <NewMenu> xx = new List <NewMenu>();
         using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + Server.MapPath(string.Format("~/App_Data/{0}", appDataBase)))) {
             connection.Open();
             string sql = string.Format(@"SELECT id, title, diet, note, energy
                     FROM menues WHERE language = '{0}'
                     ORDER BY rowid ASC", lang);
             using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
                 Clients.Client client = new Clients.Client();
                 using (SQLiteDataReader reader = command.ExecuteReader()) {
                     while (reader.Read())
                     {
                         NewMenu x = new NewMenu();
                         x.id     = reader.GetValue(0) == DBNull.Value ? "" : reader.GetString(0);
                         x.title  = reader.GetValue(1) == DBNull.Value ? "" : reader.GetString(1);
                         x.diet   = reader.GetValue(2) == DBNull.Value ? "" : reader.GetString(2);
                         x.note   = reader.GetValue(3) == DBNull.Value ? "" : reader.GetString(3);
                         x.energy = reader.GetValue(4) == DBNull.Value ? 0 : Convert.ToDouble(reader.GetString(4));
                         xx.Add(x);
                     }
                 }
             }
         }
         return(JsonConvert.SerializeObject(xx, Formatting.None));
     } catch (Exception e) {
         L.SendErrorLog(e, lang, null, "Menues", "LoadAppMenues");
         return(JsonConvert.SerializeObject(e.Message, Formatting.None));
     }
 }
Пример #14
0
 public Clients.Client ViewToModel()
 {
     Clients.Client c = new Clients.Client
     {
         Address        = txtAddress.Text,
         CompanyAddress = txtCompanyAddress.Text,
         CompanyName    = txtCompanyName.Text,
         CompanyPhone   = txtCompanyPhone.Text,
         Fax            = txtFax.Text,
         mobile         = txtMobile.Text,
         name           = txtName.Text,
         nickName       = txtNikname.Text,
         phone          = txtPhone.Text,
         type           = Clients.ConvertClientType(cbType.Text)
     };
     if (string.IsNullOrEmpty(SPI) || string.IsNullOrWhiteSpace(SPI))
     {
         c.ID = 0;
     }
     else
     {
         c.ID = Convert.ToInt32(SPI);
     }
     return(c);
 }
Пример #15
0
        // GET: All stream items
        /// <summary>
        ///
        /// </summary>
        /// <param name="id">Chain</param>
        /// <param name="stream">Stream</param>
        /// <returns></returns>
        public async Task <ActionResult> Index(String id, String stream)
        {
            Models.ChainSettings setting = Global.Chains.SingleOrDefault(s => s.Name == id);
            using (Clients.Client client = new Clients.Client(setting.Host, setting.RPCUser, setting.RPCPassword, setting.Port))
            {
                var response = await client.ListStreamItems(id, stream);

                return(View(response.Result));
            }
        }
Пример #16
0
    private NewMenu GetData(SQLiteDataReader reader, string userId)
    {
        Clients.Client client = new Clients.Client();
        NewMenu        x      = new NewMenu();

        x.id          = reader.GetValue(0) == DBNull.Value ? "" : reader.GetString(0);
        x.title       = reader.GetValue(1) == DBNull.Value ? "" : reader.GetString(1);
        x.diet        = reader.GetValue(2) == DBNull.Value ? "" : reader.GetString(2);
        x.date        = reader.GetValue(3) == DBNull.Value ? DateTime.UtcNow.ToString() : reader.GetString(3);
        x.note        = reader.GetValue(4) == DBNull.Value ? "" : reader.GetString(4);
        x.userId      = reader.GetValue(5) == DBNull.Value ? "" : reader.GetString(5);
        x.client      = (reader.GetValue(6) == DBNull.Value || reader.GetValue(7) == DBNull.Value) ? new Clients.NewClient() : client.GetClient(reader.GetString(7), reader.GetString(6));
        x.userGroupId = reader.GetValue(7) == DBNull.Value ? "" : reader.GetString(7);
        x.energy      = reader.GetValue(8) == DBNull.Value ? 0 : Convert.ToDouble(reader.GetString(8));
        string data = reader.GetValue(9) == DBNull.Value ? null : reader.GetString(9);

        if (!string.IsNullOrWhiteSpace(data))
        {
            x.data = JsonConvert.DeserializeObject <Data>(data);  // new sistem: menu saved in db
        }
        else
        {
            string jsonData = GetJsonFile(userId, x.id);   // old sistem: menu saved in json file.
            if (!string.IsNullOrWhiteSpace(jsonData))
            {
                x.data = JsonConvert.DeserializeObject <Data>(jsonData);
            }
        }
        if (x.data.selectedFoods.Count == 0)
        {
            x.data.selectedFoods     = new List <Foods.NewFood>();
            x.data.selectedInitFoods = new List <Foods.NewFood>();
            Meals M = new Meals();
            x.data.meals = M.LoadData();
        }
        if (x.data != null)
        {
            x.splitMealDesc = MealTitleDesc(x.data.meals);
        }
        x.client.clientData = new ClientsData.NewClientData();
        string myMeals = reader.GetValue(10) == DBNull.Value ? null : reader.GetString(10);

        if (!string.IsNullOrWhiteSpace(myMeals))
        {
            x.client.clientData.myMeals = JsonConvert.DeserializeObject <MyMeals.NewMyMeals>(myMeals); // new sistem: myMeals saved in db
        }
        else
        {
            x.client.clientData.myMeals = JsonConvert.DeserializeObject <MyMeals.NewMyMeals>(GetMyMealsJsonFile(userId, x.id)); // old sistem: myMeals saved in json file.
        }
        return(x);
    }
Пример #17
0
 public void AddClient(Clients.Client client)
 {
     foreach (var group in list)
     {
         if (group.HasClient(client))
         {
             group.UpdateClientHandle(client);
             return;
         }
     }
     // add to guests if we're at this point
     list[0].Add(new GroupMember(client));
 }
        public async Task <ActionResult> Create(Models.DTOs.Entity dto)
        {
            //push to chain
            Models.ChainSettings setting = Global.Chains.SingleOrDefault(s => s.Name == id);

            using (Clients.Client client = new Clients.Client(setting.Host, setting.RPCUser, setting.RPCPassword, setting.Port))
            {
                String hex      = Helpers.SerialisationHelper.ToHex(dto);
                var    response = await client.PublishStreamItem(id, "Entity", dto.Id.ToString(), hex);

                ViewBag.Response = "";
                return(RedirectToAction("Index"));
            }
        }
Пример #19
0
        private void SelectPersonal()
        {
            txtBestankar.Text = "0";
            if (dgvPersonalsList.CurrentCell != null)
            {
                int rowIndex = dgvPersonalsList.CurrentCell.RowIndex;
                //int cellIndex = dgvSeller.CurrentCell.ColumnIndex;
                int cellIndex = 0;

                if (c.getClientsList("").Rows.Count > 0)
                {
                    string PersonalCode = dgvPersonalsList.Rows[rowIndex].Cells[cellIndex].Value.ToString();
                    string PersonalName = "";

                    //DataTable dtP = new DataTable();
                    //dtP = GS.db.Query("SELECT * FROM `personals` WHERE `id`='" + PersonalCode + "'");

                    cSC = c.getClientByID(Convert.ToInt32(PersonalCode));

                    PersonalName = cSC.name;

                    ////////////////////////////// Start Set Personal Details to windows form ////////////////////////
                    txtName.Text     = PersonalName;
                    CurrentPesonalID = cSC.ID.ToString();
                    txtPhone.Text    = cSC.phone;
                    txtAddress.Text  = cSC.Address;
                    cbType.Text      = cSC.type.ToString();
                    ////////////////////////////// End Set Personal Details to windows form ////////////////////////

                    btnCalcPersonalAccountStatus.Visible = true;
                    gbPersonalsList.Visible        = false;
                    ToolStripMenuItemPay.Enabled   = true;
                    TSMIShowAccountDetails.Enabled = true;
                    tsmiAddDue.Enabled             = true;
                    this.AcceptButton = null;
                }
                else
                {
                    ResetForm();
                    MessageBox.Show("مشتری یا فروشنده ای در سیستم تعریف نشده است.");
                }
                //txtStoreItemCode.Focus();

                calcPesonalAccountStatus();
            }
            else
            {
                MessageBox.Show("فروشنده یا مشتری مورد نظر شما در سیستم تعریف نشده است.");
            }////// End control dgvPersonalsList.CurrentCell
        }
Пример #20
0
        public async Task <ActionResult> Details(String id)
        {
            Models.ChainSettings setting = Global.Chains.SingleOrDefault(s => s.Name == id);
            using (Clients.Client client = new Clients.Client(setting.Host, setting.RPCUser, setting.RPCPassword, setting.Port))
            {
                var response = await client.GetInfo(id);

                ViewModels.ChainViewModel model = new ViewModels.ChainViewModel()
                {
                    Name    = id,
                    Version = response.Result.Version,
                    Balance = response.Result.Balance
                };

                return(View(model));
            }
        }
Пример #21
0
        public void ModelToView(Clients.Client client)
        {
            ////////////////////////////// Start Set Personal Details to windows form ////////////////////////
            txtName.Text = client.name;
            //CurrentPesonalID = dtP.Rows[0]["id"].ToString();
            txtPhone.Text   = client.phone;
            txtFax.Text     = client.Fax;
            txtMobile.Text  = client.mobile;
            txtAddress.Text = client.Address;
            //cbType.Text = Clients.ConvertClientType(client.type);
            cbType.Text     = client.TypeToString();
            txtNikname.Text = client.nickName;

            txtCompanyAddress.Text = client.CompanyAddress;
            txtCompanyName.Text    = client.CompanyName;
            txtCompanyPhone.Text   = client.CompanyPhone;
        }
Пример #22
0
        /// <summary>
        /// Stream
        /// </summary>
        /// <param name="id">Chain name</param>
        /// <returns></returns>
        public async Task <ActionResult> Post(ViewModels.AddStreamKeyValueViewModel viewModel)
        {
            Models.ChainSettings setting = Global.Chains.SingleOrDefault(s => s.Name == viewModel.Name);
            using (Clients.Client client = new Clients.Client(setting.Host, setting.RPCUser, setting.RPCPassword, setting.Port))
            {
                //var response = await client.GetStreams(id);

                //ViewModels.ChainViewModel model = new ViewModels.ChainViewModel()
                //{
                //    Name = id,
                //    Version = response.Result.Version,
                //    Balance = response.Result.Balance
                //};

                return(View());
            }
        }
Пример #23
0
 public void ClientHasGone(Clients.Client client)
 {
     foreach (var group in list)
     {
         if (group.HasClient(client))
         {
             if (group.name == "Guests")
             {
                 group.Remove(client);
             }
             else
             {
                 group.ClearHandle(client);
             }
             return;
         }
     }
 }
Пример #24
0
        /// <summary>
        /// Get data
        /// </summary>
        /// <param name="id">Chain</param>
        /// <returns></returns>
        public async Task <ActionResult> Index()
        {
            Models.ChainSettings setting = Global.Chains.SingleOrDefault(s => s.Name == id);
            using (Clients.Client client = new Clients.Client(setting.Host, setting.RPCUser, setting.RPCPassword, setting.Port))
            {
                var response = await client.ListStreamItems(id, stream);

                List <Models.DTOs.DataEntity> entities = new List <Models.DTOs.DataEntity>();

                foreach (Models.ListStreamsItems.Result result in response.Result)
                {
                    Models.DTOs.DataEntity entity = Helpers.SerialisationHelper.ToObject <Models.DTOs.DataEntity>(result.Data);
                    entities.Add(entity);
                }

                return(View(entities));
            }
        }
Пример #25
0
 public Recipes.NewRecipe GetRecipeById(string id)
 {
     Recipes.NewRecipe x = new Recipes.NewRecipe();
     x.sharingData = InitSharingData();
     using (SQLiteConnection connection = new SQLiteConnection(string.Format("Data Source={0}", Server.MapPath(dataSource)))) {
         connection.Open();
         string sql = string.Format("SELECT {0} FROM recipes WHERE id = '{1}'", mainSql, id);
         using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
             Clients.Client client = new Clients.Client();
             using (SQLiteDataReader reader = command.ExecuteReader()) {
                 while (reader.Read())
                 {
                     x = GetData(reader);
                 }
             }
         }
     }
     return(x);
 }
Пример #26
0
 public string Get(string userId, string id, bool isForEdit)        // ***** isForEdit (only for save as my recipe) *****
 {
     try {
         Recipes.NewRecipe x = new Recipes.NewRecipe();
         if (!string.IsNullOrEmpty(id))
         {
             using (SQLiteConnection connection = new SQLiteConnection(string.Format("Data Source={0}", Server.MapPath(dataSource)))) {
                 connection.Open();
                 string sql = string.Format("SELECT {0} FROM recipes WHERE id = '{1}'", mainSql, id);
                 using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
                     Clients.Client client = new Clients.Client();
                     using (SQLiteDataReader reader = command.ExecuteReader()) {
                         while (reader.Read())
                         {
                             x = GetData(reader);
                         }
                     }
                 }
             }
             x.data = R.GetRecipeData(x.sharingData.recipeOwner.userGroupId, x.id);
             x.sharingData.recipeId = x.id;
             // x.mealGroup.title = R.GetMealGroupTitle(x.mealGroup.code);
             x.recipeImg     = Recipes.GetRecipeImg(x.sharingData.recipeOwner.userGroupId, x.id);
             x.recipeImgPath = Recipes.GetRecipeImgPath(userId, id, x.recipeImg);
             x.mealGroups    = R.InitMealGroups(x.mealGroup.code);
             x.userId        = userId;
             if (x.userId != null && x.userId != x.sharingData.recipeOwner.userId && isForEdit)
             {
                 x.id = null;
             }
             x.isShared       = true;
             x.dishDesc       = new Meals.DishDesc();
             x.dishDesc.title = x.title;
             x.dishDesc.desc  = x.description;
             x.dishDesc.id    = x.id;
         }
         return(JsonConvert.SerializeObject(x, Formatting.None));
     } catch (Exception e) {
         L.SendErrorLog(e, id, userId, "SharingRecipes", "Get");
         return(e.Message);
     }
 }
Пример #27
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Clients.Client newClient = ViewToModel();
            if (InEdit == true)
            {
                if (newClient.ID == 0)
                {
                    MessageBox.Show("مشتری به درستی انتخاب نشده است.");
                    return;
                }
                Clients.Items.Update(newClient);
            }
            else if (InNew == true)
            {
                Clients.Items.Add(newClient);
            }

            LoadPersonal("DESC");
            ResetForm();
        }
Пример #28
0
    private Menues.NewMenu GetData(SQLiteDataReader reader, string userId, string lang)
    {
        Clients.Client client = new Clients.Client();
        Menues.NewMenu x      = new Menues.NewMenu();
        x.id                              = reader.GetValue(0) == DBNull.Value ? null : reader.GetString(0);
        x.title                           = reader.GetValue(1) == DBNull.Value ? null : reader.GetString(1);
        x.diet                            = reader.GetValue(2) == DBNull.Value ? null : reader.GetString(2);
        x.date                            = reader.GetValue(3) == DBNull.Value ? DateTime.UtcNow.ToString() : reader.GetString(3);
        x.note                            = reader.GetValue(4) == DBNull.Value ? null : reader.GetString(4);
        x.userId                          = reader.GetValue(5) == DBNull.Value ? null : reader.GetString(5);
        x.userId                          = reader.GetValue(6) == DBNull.Value ? null : reader.GetString(6);
        x.userGroupId                     = reader.GetValue(7) == DBNull.Value ? null : reader.GetString(7);
        x.nutritionStandard               = new NewNutritionStandard();
        x.nutritionStandard.code          = reader.GetValue(8) == DBNull.Value ? null : reader.GetString(8);
        x.nutritionStandard               = GetNutritionStandardData(x.nutritionStandard.code, lang);
        x.nutritionStandard.module        = new NewModule();
        x.nutritionStandard.module.code   = reader.GetValue(9) == DBNull.Value ? null : reader.GetString(9);
        x.nutritionStandard.module        = GetModuleData(x.nutritionStandard.module.code, lang, x.nutritionStandard.age);
        x.energy                          = reader.GetValue(10) == DBNull.Value ? 0 : Convert.ToDouble(reader.GetString(10));
        x.nutritionStandard.energy        = reader.GetValue(11) == DBNull.Value ? 0 : Convert.ToDouble(reader.GetString(11));
        x.nutritionStandard.module.energy = reader.GetValue(12) == DBNull.Value ? 0 : Convert.ToDouble(reader.GetString(12));
        string data = reader.GetValue(13) == DBNull.Value ? null : reader.GetString(13);

        if (!string.IsNullOrWhiteSpace(data))
        {
            x.data = JsonConvert.DeserializeObject <Menues.Data>(data);
        }
        if (x.data.selectedFoods.Count == 0)
        {
            x.data.selectedFoods     = new List <Foods.NewFood>();
            x.data.selectedInitFoods = new List <Foods.NewFood>();
            x.data.meals             = GetModuleData(x.nutritionStandard.code, null, x.nutritionStandard.age).meals;
        }
        if (x.data != null)
        {
            Menues M = new Menues();
            x.splitMealDesc = M.MealTitleDesc(x.data.meals);
        }
        x.client.clientData = new ClientsData.NewClientData();
        return(x);
    }
Пример #29
0
        private void btnImportPersonals_Click(object sender, EventArgs e)
        {
            var myDataTable = new DataTable();

            openFileDialog1.ShowDialog(this);
            if (string.IsNullOrEmpty(openFileDialog1.FileName))
            {
                MessageBox.Show("هیچ فایلی انتخاب نشده است.");
                return;
            }
            string dbFile = openFileDialog1.FileName;

            using (var conection = new OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;" + "data source=" + dbFile + ";"))
                using (DataTable dt = new DataTable())
                {
                    string query = "Select * From `tblmembers`";
                    using (OleDbDataAdapter adapter = new OleDbDataAdapter(query, conection))
                    {
                        adapter.Fill(dt);
                    }
                    foreach (DataRow dr in dt.Rows)
                    {
                        Clients.Client newClient = new Clients.Client();
                        newClient.Address        = dr["address"].ToString();
                        newClient.CompanyAddress = "";
                        newClient.CompanyName    = "";
                        newClient.CompanyPhone   = "";
                        newClient.Fax            = "";
                        newClient.mobile         = dr["phone"].ToString();
                        newClient.name           = dr["mname"].ToString() + (!string.IsNullOrEmpty(dr["fathername"].ToString()) ? " - " + dr["fathername"].ToString() : "");
                        newClient.nickName       = "";
                        newClient.phone          = dr["phone"].ToString();
                        newClient.type           = Clients.ClientType.Customer;

                        Clients.Items.Add(newClient);
                    }
                    MessageBox.Show(dt.Rows.Count.ToString());
                }
        }
Пример #30
0
    public static void DeleteClient(ref DataContext db)
    {
        Console.WriteLine();
        Console.WriteLine("До удаления");
        Table<Clients.Client> clients = db.GetTable<Clients.Client>();

        foreach (var cl in db.GetTable<Clients.Client>().OrderByDescending(u => u.Id).Take(5))
        {
            Console.WriteLine("{0} \t{1} \t{2} \t{3} \t{4}", cl.Id, cl.Surname, cl.Name, cl.Phone, cl.Email);
        }

        Clients.Client client = db.GetTable<Clients.Client>().OrderByDescending(u => u.Id).FirstOrDefault();
        clients.DeleteOnSubmit(client);
        db.SubmitChanges();

        Console.WriteLine();
        Console.WriteLine("После удаления");
        foreach (var cl in db.GetTable<Clients.Client>().OrderByDescending(u => u.Id).Take(5))
        {
            Console.WriteLine("{0} \t{1} \t{2} \t{3} \t{4}", cl.Id, cl.Surname, cl.Name, cl.Phone, cl.Email);
        }
    }
Пример #31
0
 void MyMethod()
 {
     Clients.Client c = new Clients.Client();
 }