Пример #1
0
        byte[] LoadFileFromDB(int id)
        {
            logger.Info("Получаем файл id={0}", id);
            string sql = String.Format("SELECT file, size FROM {0} WHERE id = @id",
                                       TableName);

            try {
                byte[]       file;
                MySqlCommand cmd = new MySqlCommand(sql, (MySqlConnection)QSMain.ConnectionDB);
                cmd.Parameters.AddWithValue("@id", id);
                using (MySqlDataReader rdr = cmd.ExecuteReader()) {
                    rdr.Read();

                    file = new byte[rdr.GetInt64("size")];
                    rdr.GetBytes(rdr.GetOrdinal("file"), 0, file, 0, rdr.GetInt32("size"));
                    TreeIter iter;
                    ListStoreWorks.SearchListStore(FilesStore, id, (int)FilesCol.id, out iter);
                    FilesStore.SetValue(iter, (int)FilesCol.file, (object)file);
                    FilesStore.SetValue(iter, (int)FilesCol.size, (object)rdr.GetInt64("size"));
                }
                logger.Info("Ок");
                return(file);
            } catch (Exception ex) {
                string mes = "Получения файла из базы!";
                logger.Error(ex, mes);
                throw new ApplicationException(mes, ex);
            }
        }
Пример #2
0
        private void Fill()
        {
            var sql = "SELECT * FROM order_pays op" +
                      " LEFT JOIN employee_service_work  esw on op.id = esw.id_order_pay" +
                      " WHERE order_id = @id";
            var cmd = new MySqlCommand(sql, QSMain.connectionDB);

            cmd.Parameters.AddWithValue("@id", Entity.Id);
            using (MySqlDataReader rdr = cmd.ExecuteReader())
            {
                TreeIter iter;
                while (rdr.Read())
                {
                    if (ListStoreWorks.SearchListStore(ServiceListStore, rdr.GetInt32("service_id"), 0, out iter))
                    {
                        ServiceListStore.SetValue(iter, 1, true);
                        ServiceListStore.SetValue(iter, 3, rdr.GetDouble("cost"));
                        ServiceListStore.SetValue(iter, 4, (object)rdr.GetInt64("id"));
                        if (rdr["id_employee"].ToString().Length > 0)
                        {
                            int i = 5;
                            foreach (var emp in listPerformers)
                            {
                                if (emp.Id == rdr.GetInt32("id_employee"))
                                {
                                    break;
                                }
                                i++;
                            }
                            ServiceListStore.SetValue(iter, i, true);
                        }
                    }
                    else
                    {
                        ServiceListStore.AppendValues(rdr.GetInt32("service_id"),
                                                      true,
                                                      "исключенная услуга",
                                                      rdr.GetDouble("cost"),
                                                      (object)rdr.GetInt64("id")
                                                      );
                    }
                }
            }
            CalculateTotal();
            buttonDelete.Sensitive = true;
            logger.Info("Ok");

            TestCanSave();
        }
Пример #3
0
        private void Fill()
        {
            var sql = "select shw.id as shw_id, emp.id as emp_id, emp.first_name, emp.last_name, emp.patronymic from employees emp " +
                      " left join shedule_employee_works shew on shew.id_employee = emp.id" +
                      " left join shedule_works shw on shew.id_shedule_works = shw.id" +
                      " where shw.id = @id" +
                      " order by shw.id desc, emp.first_name;";
            var cmd = new MySqlCommand(sql, QSMain.connectionDB);

            cmd.Parameters.AddWithValue("@id", Entity.Id);
            using (MySqlDataReader rdr = cmd.ExecuteReader())
            {
                TreeIter iter;
                while (rdr.Read())
                {
                    if (ListStoreWorks.SearchListStore(EmployeeWorkList, rdr.GetInt32("emp_id"), 0, out iter))
                    {
                        EmployeeWorkList.SetValue(iter, 1, true);
                    }
                }
            }

            sql = "select emp.id, emp.first_name, emp.last_name, emp.patronymic " +
                  " FROM employee_service_work esw" +
                  " LEFT JOIN employees emp on esw.id_employee = emp.id " +
                  " LEFT JOIN order_pays op on esw.id_order_pay = op.id" +
                  " LEFT JOIN orders on orders.id = op.order_id" +
                  " WHERE orders.date = @date AND orders.point_number = @point_number AND orders.calendar_number = @calendar_number";
            cmd = new MySqlCommand(sql, QSMain.connectionDB);
            cmd.Parameters.AddWithValue("@date", Entity.DateWork);
            cmd.Parameters.AddWithValue("@point_number", Entity.PointNumber);
            cmd.Parameters.AddWithValue("@calendar_number", Entity.CalendarNumber);
            using (MySqlDataReader rdr = cmd.ExecuteReader())
            {
                TreeIter iter;
                while (rdr.Read())
                {
                    if (ListStoreWorks.SearchListStore(EmployeeWorkList, rdr.GetInt32("id"), 0, out iter))
                    {
                        EmployeeWorkList.SetValue(iter, 1, true);
                        EmployeeWorkList.SetValue(iter, 5, true);
                    }
                }
            }
            CalculateTotal();
            logger.Info("Ok");
        }
        void CategoryCombo_Edited(object o, EditedArgs args)
        {
            TreeIter iter, refIter;

            if (!documents.GetIterFromString(out iter, args.Path))
            {
                return;
            }
            if (String.IsNullOrWhiteSpace(args.NewText))
            {
                return;
            }
            documents.SetValue(iter, (int)Columns.CategoryName, args.NewText);
            var listStore = (ListStore)documents.GetValue(iter, (int)Columns.CategoryComboModel);

            if (ListStoreWorks.SearchListStore(listStore, args.NewText, out refIter))
            {
                var selected = listStore.GetValue(refIter, 1);
                documents.SetValue(iter, (int)Columns.CategoryObject, selected);
            }
        }
Пример #5
0
        void UpdateFieldsWidgets(bool ChangeTypeCombo)
        {
            logger.Debug("Update widgets");
            //Удаляем старые виджеты
            foreach (KeyValuePair <int, Label> pair in FieldLables)
            {
                tableFieldWidgets.Remove(pair.Value);
                pair.Value.Destroy();
            }
            FieldLables.Clear();
            foreach (KeyValuePair <int, object> pair in FieldWidgets)
            {
                tableFieldWidgets.Remove((Widget)pair.Value);
                ((Widget)pair.Value).Destroy();
            }
            FieldWidgets.Clear();
            foreach (KeyValuePair <int, Gtk.Image> pair in FieldIcons)
            {
                tableFieldWidgets.Remove(pair.Value);
                pair.Value.Destroy();
            }
            FieldIcons.Clear();
            Clearing = true;
            if (ChangeTypeCombo)
            {
                comboType.Active = -1;
            }
            comboType.Sensitive = ImageList.IterIsValid(CurrentDocIter);
            entryNumber.Text    = "";
            dateDoc.Clear();
            Clearing = false;

            if (CurrentDoc == null)
            {
                logger.Warn("Doc is empty");
                entryNumber.Sensitive = false;
                dateDoc.Sensitive     = false;
                return;
            }
            //Создаем новые
            if (CurrentDoc.FieldsList != null)
            {
                uint Row = 4;
                foreach (DocFieldInfo field in CurrentDoc.FieldsList)
                {
                    Label NameLable = new Label(field.Name + ":");
                    NameLable.Xalign = 1;
                    tableFieldWidgets.Attach(NameLable, 0, 1, Row, Row + 1,
                                             AttachOptions.Fill, AttachOptions.Fill, 0, 0);
                    FieldLables.Add(field.ID, NameLable);
                    object ValueWidget;
                    switch (field.Type)
                    {
                    case "varchar":
                        ValueWidget = new Entry();
                        ((Entry)ValueWidget).Changed += OnExtraFieldEntryChanged;
                        break;

                    default:
                        ValueWidget = new Label();
                        break;
                    }
                    tableFieldWidgets.Attach((Widget)ValueWidget, 1, 2, Row, Row + 1,
                                             AttachOptions.Fill, AttachOptions.Fill, 0, 0);
                    FieldWidgets.Add(field.ID, ValueWidget);

                    Gtk.Image ConfIcon = new Gtk.Image();
                    tableFieldWidgets.Attach(ConfIcon, 2, 3, Row, Row + 1,
                                             AttachOptions.Fill, AttachOptions.Fill, 0, 0);
                    FieldIcons.Add(field.ID, ConfIcon);

                    Row++;
                }
            }
            tableFieldWidgets.ShowAll();

            //Заполняем данными текущего документа
            TreeIter iter;

            Clearing = true;
            if (ChangeTypeCombo)
            {
                ListStoreWorks.SearchListStore((ListStore)comboType.Model, CurrentDoc.TypeId, out iter);
                comboType.SetActiveIter(iter);
            }
            entryNumber.Text      = CurrentDoc.DocNumber;
            entryNumber.Sensitive = true;
            SetRecognizeIcon(IconNumber, CurrentDoc.DocNumberConfidence);
            dateDoc.Date      = CurrentDoc.DocDate;
            dateDoc.Sensitive = true;
            SetRecognizeIcon(IconDate, CurrentDoc.DocDateConfidence);
            Clearing = false;

            if (CurrentDoc.FieldsList != null)
            {
                foreach (DocFieldInfo field in CurrentDoc.FieldsList)
                {
                    if (CurrentDoc.FieldValues[field.ID] == null)
                    {
                        continue;
                    }

                    switch (field.Type)
                    {
                    case "varchar":
                        ((Entry)FieldWidgets[field.ID]).Text = (string)CurrentDoc.FieldValues[field.ID];
                        break;

                    default:
                        Console.WriteLine("Неизвестный тип поля");
                        break;
                    }

                    SetRecognizeIcon(FieldIcons[field.ID], CurrentDoc.FieldConfidence[field.ID]);
                }
            }
        }