예제 #1
0
        public CreateNewRow(SQLExecuter executer, DataGridView dataGridView, CurrentTable currentTable)
        {
            InitializeComponent();
            Executer     = executer;
            CurrentTable = currentTable;
            DialogResult = DialogResult.Cancel;
            dataGridView_AddRow.AllowUserToAddRows    = false;
            dataGridView_AddRow.AllowUserToDeleteRows = false;
            string columnName;

            for (int i = 0; i < dataGridView.ColumnCount; i++)
            {
                columnName = dataGridView.Columns[i].Name;
                if (currentTable.Dependences.Dependence.ContainsKey(columnName))
                {
                    dataGridView_AddRow.Columns.Add(
                        new DataGridViewComboBoxColumn()
                    {
                        DataSource = currentTable.Dependences.Dependence[columnName]
                    });
                }
                else
                {
                    dataGridView_AddRow.Columns.Add(dataGridView.Columns[i].Name, dataGridView.Columns[i].Name);
                }
            }
            dataGridView_AddRow.Rows.Add();
        }
예제 #2
0
        internal static void f_remove(SQLExecuter sqlex, bool keepConnectionOpen, OEntry obj)
        {
            try {
                #region handle children
                // bool leave;

                //set null
                //while (true) {
                //    leave = true;
                //    foreach (OEmployee x in OEmployee.Obscol) {
                //        if (x.p_department.p_id == obj.p_id) {
                //            OEmployee.f_addEdit(sqlex, true, true, x, null, x.p_employee_boss,
                //                x.p_name, x.p_birthday);
                //            leave = false;
                //            break;
                //        }
                //    }
                //    if (leave) break;
                //}
                #endregion

                //exec sql statement
                sqlex.delete(DB_TABLE, "where pk=" + obj.p_id, keepConnectionOpen);

                //remove this from obscol
                Obscol.Remove(obj);
            } catch (Exception exc) {
                throw exc;
            }
        }
        protected override bool InvokeUpgradeCore(SQLExecuter sqlExecuter)
        {
            using (var tran = sqlExecuter.BeginTransaction())
            {
                try
                {
                    sqlExecuter.Execute("ALTER TABLE MOVLIST ADD COLUMN SEASON TEXT");

                    var libraries = sqlExecuter.Query<LibraryItem>("SELECT * FROM MOVLIST");

                    foreach (var library in libraries)
                    {
                        var season = string.Format(ApplicationDefinitions.SeasonFormat, library.Date.Year, DateUtils.GetSeasonString(library.Date));

                        sqlExecuter.Execute("UPDATE MOVLIST SET SEASON = @Season WHERE ID = @Id", new { Id = library.Id, Season = season });
                    }

                    tran.Commit();
                }
                catch (SQLiteException ex)
                {
                    tran.Rollback();
                    _log.Error(ex);
                    return false;
                }
            }
            return true;
        }
예제 #4
0
        /// <summary>
        /// set sqlex and fill obscols
        /// </summary>
        private void f_initializeData()
        {
            try {
                //init sqlex to load out and manage the db content
                _sqlExecuter = new SQLExecuter(Path.Combine(Environment.CurrentDirectory, "data.accdb"));

                //fill item sources
                p_departments = OEntry.f_selectAndConvertData(_sqlExecuter, false, "");
            } catch (Exception exc) {
                throw exc;
            }
        }
예제 #5
0
        private void UpdateClientsList(int selected = ConstValues.NullIndex)
        {
            using SQLExecuter sql = new SQLExecuter(parentForm.Settings.ConnectionString);
            sql.ExecuteStoreProcedureWithoutParameters(nameof(SQLEnums.StoredProcedureNames.ОбнулитьПустыеДопИнфоКлиентов));
            sql.ExecuteStoreProcedureWithoutParameters(nameof(SQLEnums.StoredProcedureNames.УдалитьПустыеДопИнфо));

            using ClientData data = new ClientData(parentForm.Settings.ConnectionString);
            if (showArchived.Checked)
            {
                clientCollection = data.GetDataCollection();
            }
            else
            {
                clientCollection = data.GetDataCollection().Where(x => !archiveCollection.Any(a => a.Client.ID.Equals(x.ID))).ToList();
            }

            ClientsList.Items.Clear();
            foreach (ClientModel client in clientCollection)
            {
                List <string> clientRow = new List <string>
                {
                    client.MiddleName,
                    client.FirstName,
                    client.LastName,
                    client.ContactNumber,
                    client.AddtionalInfo != null ? client.AddtionalInfo.AdditionalContactNumber : string.Empty,
                    client.AddtionalInfo != null ? client.AddtionalInfo.Address : string.Empty,
                    client.AddtionalInfo != null ? client.AddtionalInfo.Preferences : string.Empty,
                    client.OrdersCount.ToString()
                };
                ListViewItem sourceItem = new ListViewItem(clientRow.ToArray());
                if (archiveCollection.Any(x => x.Client.ID.Equals(client.ID)))
                {
                    sourceItem.BackColor = ArchiveReasonColor;
                }
                else
                {
                    sourceItem.BackColor = client.AddtionalInfo == null ? ColdClientColor : HotClientColor;
                }

                ClientsList.Items.Add(sourceItem);
            }
            if (!selected.Equals(ConstValues.NullIndex) &&
                !ClientsList.Items.Count.Equals(ConstValues.Zero) &&
                selected < ClientsList.Items.Count)
            {
                ClientsList.Items[selected].Selected = true;
            }
        }
예제 #6
0
        public static ObservableCollection <OEntry> f_selectAndConvertData(SQLExecuter sqlex, bool keepConnectionOpen, string where)
        {
            Obscol = new ObservableCollection <OEntry>();
            foreach (object[] row in sqlex.select(DB_TABLE, "", where, keepConnectionOpen))
            {
                int      id      = Convert.ToInt32(row[0]);
                string   name    = Convert.ToString(row[1]);
                string   message = Convert.ToString(row[2]);
                DateTime date    = Convert.ToDateTime(row[3]);

                Obscol.Add(new OEntry {
                    p_id = id, p_name = name, p_message = message, p_date = date
                });
            }
            return(Obscol);
        }
예제 #7
0
        internal static OEntry f_addEdit(SQLExecuter sqlex, bool keepConnectionOpen, bool toActualObscol, OEntry obj, string name, string message, DateTime date)
        {
            try {
                //add
                if (obj == null)
                {
                    //insert object into collection
                    Obscol.Add(new OEntry {
                        p_name    = name,
                        p_message = message,
                        p_date    = date
                    });

                    //insert entity and identify pk
                    int id = sqlex.insert(DB_TABLE, Obscol[Obscol.Count - 1].f_getDBTableRow(), keepConnectionOpen);

                    //overwrite determined primary key for entity
                    obj      = Obscol[Obscol.Count - 1];
                    obj.p_id = id;
                }

                //edit
                else
                {
                    //overwrite properties
                    obj.p_name    = name;
                    obj.p_message = message;
                    obj.p_date    = date;

                    //call update
                    sqlex.update(DB_TABLE, obj.f_getDBTableRow(), keepConnectionOpen);
                }

                if (!toActualObscol)
                {
                    Obscol.Remove(obj);
                }

                return(obj);
            } catch (Exception exc) {
                throw exc;
            }
        }
예제 #8
0
        public UCMessage_AddEditCtrl(SQLExecuter sqlex, WMain wmain, OEntry o)
        {
            _wmain              = wmain;
            _sqlExecuter        = sqlex;
            _selectedDepartment = o;
            f_initializeData();

            //cmd
            p_cmd_apply  = new RelayCommand(f_cmd_apply);
            p_cmd_cancel = new RelayCommand(f_cmd_cancel);

            //pres
            UCDepartment_AddEdit uc = new UCDepartment_AddEdit(this);

            wmain.c_stack_form.Children.Add(uc);
            if (o != null)
            {
                uc.c_tb_name.SelectedText = o.p_name;
                uc.c_tb_message.Text      = o.p_message;
            }
        }