예제 #1
0
 public void AddMsg(KeyValuePair <ImportData.MsgState, string> msg)
 {
     if (InvokeRequired)
     {
         BeginInvoke(new AddMsgDelegate(AddMsg), new object[] { msg });
         return;
     }
     else
     {
         listMsg.Add(new DataSourceMsg(imageListMsg.Images[(int)msg.Key], DateTime.Now.ToLongTimeString(), msg.Value));
         GridMsg.Invalidate();
     }
 }
예제 #2
0
        private void bActivation_Click(object sender, EventArgs e)
        {
            try
            {
                if (tabSettings.SelectedTabPageIndex == 2)
                {
                    if (tePath.Text == "")
                    {
                        MyLocalizer.XtraMessageBoxShow("Необходимо указать путь к импортируемой базе данных.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if ("data source=" + tePath.Text == global::DiarMain.Properties.Settings.Default.diarConnectionString)
                    {
                        MyLocalizer.XtraMessageBoxShow("Необходимо выбрать другую базу данных.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    listMsg.Clear();
                    GridMsg.Invalidate();

                    bActivation.Enabled = false;
                    m_bEnd = false;

                    this.Cursor = System.Windows.Forms.Cursors.WaitCursor;

                    worker.RunWorkerAsync();
                }
                else
                {
                    bool bExistModule = false;
                    for (int i = 0; i < listModules.Count; i++)
                    {
                        if (listModules[i].CHECK)
                        {
                            bExistModule = true;
                            break;
                        }
                    }

                    if (!bExistModule)
                    {
                        MyLocalizer.XtraMessageBoxShow("Необходимо включить хотя бы один модуль.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    SQLiteConnection connection = new SQLiteConnection(global::DiarMain.Properties.Settings.Default.diarConnectionString);
                    connection.Open();
                    SQLiteCommand com = new SQLiteCommand(connection);
                    com.CommandText = "UPDATE EquipmentKinds SET Disable = @disable WHERE EquipmentKindID = @id";
                    com.CommandType = CommandType.Text;
                    SQLiteParameter param  = new SQLiteParameter("@disable", DbType.Int64);
                    SQLiteParameter param2 = new SQLiteParameter("@id", DbType.Int64);

                    for (int i = 0; i < listModules.Count; i++)
                    {
                        com.Parameters.Clear();

                        param.Value  = listModules[i].CHECK ? 0 : 1;
                        param2.Value = listModules[i].ID;

                        com.Parameters.Add(param);
                        com.Parameters.Add(param2);
                        com.ExecuteNonQuery();
                    }

                    com.CommandText = "UPDATE Settings SET MainImage = @image";
                    com.Parameters.Clear();
                    SQLiteParameter param3 = new SQLiteParameter("@image", DbType.Object);
                    param3.Value = peImage.EditValue;
                    com.Parameters.Add(param3);
                    com.ExecuteNonQuery();

                    connection.Close();

                    DialogResult = System.Windows.Forms.DialogResult.OK;
                    Close();
                }
            }
            catch (SQLiteException ex)
            {
                MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (DBConcurrencyException ex)
            {
                MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }