Beispiel #1
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (m_bShowCloseMsg && MyLocalizer.XtraMessageBoxShow("Вы действительно хотите выйти из программы?", "Предупреждение", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != System.Windows.Forms.DialogResult.Yes)
     {
         e.Cancel = true;
     }
 }
Beispiel #2
0
 void QEquipmentTypes_QEquipmentTypesRowDeleted(object sender, DataSetQuery.QEquipmentTypesRowChangeEvent e)
 {
     if (e.Action == DataRowAction.Delete)
     {
         if (!m_bAcceptChanges)
         {
             e.Row.RejectChanges();
         }
         else
         {
             try
             {
                 using (var cmdBuilder = new SQLiteCommandBuilder(this.qEquipmentTypesTableAdapter.Adapter)) this.qEquipmentTypesTableAdapter.Adapter.Update(this.dataSetQuery.QEquipmentTypes);
             }
             catch (SQLiteException ex)
             {
                 MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             catch (DBConcurrencyException ex)
             {
                 MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Beispiel #3
0
        public bool Start(string strFileName)
        {
            m_pApp       = null;
            m_pDoc       = null;
            m_pTable     = null;
            m_pSelection = null;

            old_table_index = 0;

            try
            {
                m_pApp = new MSWord.Application();

                if (strFileName == "")
                {
                    m_pDoc = m_pApp.Documents.Add();
                }
                else
                {
                    m_pDoc = m_pApp.Documents.Add(strFileName);
                }

                return(true);
            }
            catch (Exception ex)
            {
                MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(false);
        }
Beispiel #4
0
        private void btnVibro_Click(object sender, EventArgs e)
        {
            /*if (MainGridView.FocusedRowHandle < 0)
             * {
             *  MyLocalizer.XtraMessageBoxShow("Необходимо указать оборудование.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             *  return;
             * }
             *
             * DataRowView drv = (DataRowView)(qMainEquipmentsBindingSource.Current);
             * long id = Convert.ToInt64(drv.Row["EquipmentID"]);
             * ShowVibroForm(id, true);
             * */

            if (MainGridView.FocusedRowHandle < 0)
            {
                MyLocalizer.XtraMessageBoxShow("Необходимо указать оборудование.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            DataRowView drv = (DataRowView)(qMainEquipmentsBindingSource.Current);
            long        id  = Convert.ToInt64(drv.Row["EquipmentID"]);

            InspectionForm form = new InspectionForm(id, Inspection.InspectionType.Vibro);

            form.ShowDialog(this);
        }
Beispiel #5
0
        private void RefreshGridPos(long id)
        {
            try
            {
                int f_row = MainGridView.FocusedRowHandle;
                if (id <= 0)
                {
                    return;
                }
                else
                {
                    FindChecks(id);

                    for (int i = 0; i < MainGridView.RowCount /*this.dataSetQuery.QEquipments.Rows.Count*/; i++)
                    {
                        //DataRow r = this.dataSetQuery.QEquipments.Rows[i];
                        //int id_ = Convert.ToInt64(r["EquipmentID"]);
                        long id_ = Convert.ToInt64(MainGridView.GetRowCellValue(i, "CheckID"));
                        if (id_ == id)
                        {
                            MainGridView.ClearSelection();
                            MainGridView.SelectRow(i);
                            MainGridView.FocusedRowHandle = i;
                            return;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #6
0
        private void cbBranch_EditValueChanged(object sender, EventArgs e)
        {
            try
            {
                long iSubjectID = -1;
                if (cbSubject.EditValue != null)
                {
                    iSubjectID = Convert.ToInt64(cbSubject.EditValue);
                }

                long iBranchID = -1;
                if (cbBranch.EditValue != null)
                {
                    iBranchID = Convert.ToInt64(cbBranch.EditValue);
                }

                this.qSubstationsByBranchTableAdapter.Fill(this.dataSetQuery.QSubstationsByBranch, iBranchID);

                if (this.dataSetQuery.QSubstationsByBranch.Rows.Count < 7)
                {
                    cbSubstation.Properties.DropDownRows = this.dataSetQuery.QSubstationsByBranch.Rows.Count;
                }
                else
                {
                    cbSubstation.Properties.DropDownRows = 7;
                }
            }
            catch (Exception ex)
            {
                MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #7
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                long id           = -1;
                long subjectID    = -1;
                long branchID     = -1;
                long substationID = -1;
                if (cbSubject.EditValue != null)
                {
                    subjectID = Convert.ToInt64(cbSubject.EditValue);
                }
                if (cbBranch.EditValue != null)
                {
                    branchID = Convert.ToInt64(cbBranch.EditValue);
                }
                if (cbSubstation.EditValue != null)
                {
                    substationID = Convert.ToInt64(cbSubstation.EditValue);
                }

                this.ShowInTaskbar = false;
                CheckDataForm cf = new CheckDataForm(id, subjectID, branchID, substationID);
                DialogResult  dr = cf.ShowDialog(this);
                this.ShowInTaskbar = true;
                id = cf.m_CheckID;
                //if (dr == System.Windows.Forms.DialogResult.OK)
                RefreshGridPos(id);
            }
            catch (Exception ex)
            {
                MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                if (m_bSuccess)
                {
                    SQLiteConnection con = new SQLiteConnection(global::DiarMain.Properties.Settings.Default.diarConnectionString);
                    con.Open();
                    SQLiteCommand com = new SQLiteCommand(con);
                    com.CommandText = "UPDATE Version SET CurVersion = @ver";
                    com.CommandType = CommandType.Text;

                    AddParam(com, "@ver", DbType.Decimal, m_CurVersion);
                    com.ExecuteNonQuery();

                    m_bEnd       = true;
                    DialogResult = System.Windows.Forms.DialogResult.OK;
                    Close();
                }
                else
                {
                    m_bEnd       = true;
                    DialogResult = System.Windows.Forms.DialogResult.Cancel;
                    Close();
                }
            }
            catch (SQLiteException ex)
            {
                MyLocalizer.XtraMessageBoxShow("Не удалось подключиться к базе данных. Описание: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Beispiel #9
0
        private void UpdateRecord()
        {
            try
            {
                if (MainGridView.FocusedRowHandle < 0)
                {
                    MyLocalizer.XtraMessageBoxShow("Необходимо указать проверку.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                DataRowView drv = (DataRowView)(qMainChecksBindingSource.Current);
                long        id  = Convert.ToInt64(drv.Row["CheckID"]);

                this.ShowInTaskbar = false;
                CheckDataForm cf = new CheckDataForm(id, -1, -1, -1);
                DialogResult  dr = cf.ShowDialog(this);
                this.ShowInTaskbar = true;
                //if (dr == System.Windows.Forms.DialogResult.OK)
                RefreshGridPos(id);
            }
            catch (Exception ex)
            {
                MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #10
0
 private void MainGridView_ShowFilterPopupListBox(object sender, DevExpress.XtraGrid.Views.Grid.FilterPopupListBoxEventArgs e)
 {
     try
     {
         string custom    = DevExpress.XtraGrid.Localization.GridLocalizer.Active.GetLocalizedString(DevExpress.XtraGrid.Localization.GridStringId.PopupFilterCustom);
         string blank     = DevExpress.XtraGrid.Localization.GridLocalizer.Active.GetLocalizedString(DevExpress.XtraGrid.Localization.GridStringId.PopupFilterBlanks);
         string not_blank = DevExpress.XtraGrid.Localization.GridLocalizer.Active.GetLocalizedString(DevExpress.XtraGrid.Localization.GridStringId.PopupFilterNonBlanks);
         for (int i = e.ComboBox.Items.Count - 1; i >= 0; i--)
         {
             if (e.ComboBox.Items[i].ToString() == custom)
             {
                 e.ComboBox.Items.RemoveAt(i);
                 continue;
             }
             if (e.ComboBox.Items[i].ToString() == blank)
             {
                 e.ComboBox.Items.RemoveAt(i);
                 continue;
             }
             if (e.ComboBox.Items[i].ToString() == not_blank)
             {
                 e.ComboBox.Items.RemoveAt(i);
                 continue;
             }
         }
     }
     catch (Exception ex)
     {
         MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #11
0
        private void AddPassportMessageForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (cbShowMessage.Checked)
            {
                SQLiteConnection con = new SQLiteConnection(global::DiarMain.Properties.Settings.Default.diarConnectionString);
                try
                {
                    con.Open();
                    SQLiteCommand com = new SQLiteCommand(con);
                    com.CommandType = CommandType.Text;
                    com.CommandText = "UPDATE Licenses SET AddPassportMessage = 1 WHERE Code = @val";
                    com.Parameters.Clear();
                    AddParam(com, "@val", DbType.String, m_strLicenseCode);
                    com.ExecuteNonQuery();
                    con.Close();

                    m_bAddPassportMessage = true;
                }
                catch (SQLiteException ex)
                {
                    MyLocalizer.XtraMessageBoxShow("Не удалось подключиться к базе данных. Описание: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }
Beispiel #12
0
        void QEquipmentTypes_QEquipmentTypesRowDeleting(object sender, DataSetQuery.QEquipmentTypesRowChangeEvent e)
        {
            try
            {
                if (e.Action == DataRowAction.Delete)
                {
                    if (Convert.ToInt64(e.Row["ReadOnly"]) != 0)
                    {
                        MyLocalizer.XtraMessageBoxShow("Недостаточно прав для удаления записи.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        m_bAcceptChanges = false;
                        return;
                    }

                    if (MyLocalizer.XtraMessageBoxShow("Удалить запись?", "Предупреждение", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                    {
                        m_bAcceptChanges = false;
                        return;
                    }
                    else
                    {
                        long id = Convert.ToInt64(e.Row["EquipmentTypeID"]);

                        SQLiteConnection connection = new SQLiteConnection(global::DiarMain.Properties.Settings.Default.diarConnectionString);
                        connection.Open();
                        SQLiteCommand com = new SQLiteCommand(connection);
                        com.CommandText = "Select COUNT(*) AS Cnt from Equipments WHERE EquipmentTypeID = ?";
                        com.CommandType = CommandType.Text;
                        SQLiteParameter param1 = new SQLiteParameter("@Param1", DbType.Int64);
                        param1.Value = id;
                        com.Parameters.Add(param1);
                        SQLiteDataReader dr = com.ExecuteReader();
                        while (dr.Read())
                        {
                            if (Convert.ToInt64(dr["Cnt"]) > 0)
                            {
                                MyLocalizer.XtraMessageBoxShow("Существует оборудование данного типа.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                m_bAcceptChanges = false;
                                dr.Close();
                                connection.Close();
                                return;
                            }
                        }
                        dr.Close();

                        m_bAcceptChanges = true;

                        connection.Close();
                    }
                }
            }
            catch (SQLiteException ex)
            {
                MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (DBConcurrencyException ex)
            {
                MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #13
0
        void QSubjects_QSubjectsRowChanged(object sender, DataSetQuery.QSubjectsRowChangeEvent e)
        {
            if (e.Action == DataRowAction.Add || e.Action == DataRowAction.Change)
            {
                /*if (!m_bAcceptChanges)
                 *  e.Row.RejectChanges();
                 * else
                 * {*/
                try
                {
                    if (e.Action == DataRowAction.Change && m_bUpdateID)
                    {
                        this.dataSetQuery.QSubjects.AcceptChanges();
                        m_bUpdateID = false;
                        return;
                    }
                    else
                    {
                        using (var cmdBuilder = new SQLiteCommandBuilder(this.qSubjectsTableAdapter.Adapter)) this.qSubjectsTableAdapter.Adapter.Update(this.dataSetQuery.QSubjects);
                    }

                    if (e.Action == DataRowAction.Add)
                    {
                        SQLiteConnection connection = new SQLiteConnection(global::DiarMain.Properties.Settings.Default.diarConnectionString);
                        connection.Open();
                        SQLiteCommand com = new SQLiteCommand(connection);
                        com.CommandText = "select seq from sqlite_sequence where name = 'Subjects'";
                        com.CommandType = CommandType.Text;
                        SQLiteDataReader dr = com.ExecuteReader();

                        long id = 0;
                        while (dr.Read())
                        {
                            id = Convert.ToInt64(dr["seq"]);
                        }
                        dr.Close();

                        m_bUpdateID = true;
                        ((DataRowView)(qSubjectsBindingSource.Current)).Row["SubjectID"] = id;

                        // добавляем филиал <без филиала>
                        com.CommandText = "INSERT INTO Branches (SubjectID, BranchName, ReadOnly) VALUES (" + id.ToString() + ", '<без филиала>', 1)";
                        com.ExecuteNonQuery();

                        connection.Close();
                    }
                }
                catch (SQLiteException ex)
                {
                    MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (DBConcurrencyException ex)
                {
                    MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                //}
            }
        }
Beispiel #14
0
        private void DeleteRecord()
        {
            try
            {
                if (GridView.FocusedRowHandle < 0)
                {
                    return;
                }

                DataRowView drv = (DataRowView)(qChecksBindingSource.Current);

                if (MyLocalizer.XtraMessageBoxShow("Удалить запись? Все обследования, связанные с данной проверкой будут удалены.", "Предупреждение", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                {
                    return;
                }
                else
                {
                    long id = Convert.ToInt64(drv.Row["CheckID"]);

                    SQLiteConnection connection = new SQLiteConnection(global::DiarMain.Properties.Settings.Default.diarConnectionString);
                    connection.Open();
                    SQLiteCommand com = new SQLiteCommand(connection);
                    com.CommandType = CommandType.Text;

                    SQLiteParameter param1 = new SQLiteParameter("@Param1", DbType.Int64);
                    param1.Value = id;
                    com.Parameters.Add(param1);

                    com.CommandText = "DELETE FROM SystemItemResults WHERE InspectionID IN (SELECT InspectionID FROM Inspections WHERE CheckID = ?)";
                    com.ExecuteNonQuery();

                    com.CommandText = "DELETE FROM FunctionalSystemResults WHERE InspectionID IN (SELECT InspectionID FROM Inspections WHERE CheckID = ?)";
                    com.ExecuteNonQuery();

                    com.CommandText = "DELETE FROM InspectionDatas WHERE InspectionID IN (SELECT InspectionID FROM Inspections WHERE CheckID = ?)";
                    com.ExecuteNonQuery();

                    com.CommandText = "DELETE FROM Inspections WHERE CheckID = ?";
                    com.ExecuteNonQuery();

                    com.CommandText = "DELETE FROM Checks WHERE CheckID = ?";
                    com.ExecuteNonQuery();

                    connection.Close();

                    RefreshGridPos(-1);
                }
            }
            catch (SQLiteException ex)
            {
                MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (DBConcurrencyException ex)
            {
                MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #15
0
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            //listModules.Add(new DataSourceModule(false, "12121"));
            //listModules.Add(new DataSourceModule(true, "45454"));

            try
            {
                SQLiteConnection connection = new SQLiteConnection(global::DiarMain.Properties.Settings.Default.diarConnectionString);
                connection.Open();
                SQLiteCommand com = new SQLiteCommand(connection);
                com.CommandText = "SELECT EquipmentKindID, EquipmentKindName, Disable FROM EquipmentKinds ORDER BY EquipmentKindID";
                com.CommandType = CommandType.Text;
                SQLiteDataReader dr = com.ExecuteReader();
                while (dr.Read())
                {
                    long   iEquipmentKindID     = Convert.ToInt64(dr["EquipmentKindID"]);
                    long   iDisable             = Convert.ToInt64(dr["Disable"]);
                    string strEquipmentKindName = Convert.ToString(dr["EquipmentKindName"]);

                    listModules.Add(new DataSourceModule(iEquipmentKindID, (iDisable == 0) ? true : false, strEquipmentKindName));
                }
                dr.Close();

                com.CommandText = "SELECT MainImage FROM Settings";

                SQLiteDataReader drImage = com.ExecuteReader();
                if (drImage.HasRows)
                {
                    while (drImage.Read())
                    {
                        peImage.EditValue = drImage["MainImage"];
                        break;
                    }
                }
                drImage.Close();

                connection.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);
            }

            GridGC.DataSource = listModules;

            GridMsg.DataSource = listMsg;
        }
Beispiel #16
0
 private void GridView_DoubleClick(object sender, EventArgs e)
 {
     if (cbCanEdit.Checked && qEquipmentTypesBindingSource.Current != null)
     {
         if (Convert.ToInt64(((DataRowView)(qEquipmentTypesBindingSource.Current)).Row["ReadOnly"]) != 0)
         {
             MyLocalizer.XtraMessageBoxShow("Недостаточно прав для редактирования записи.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
     }
 }
Beispiel #17
0
        private void bActivation_Click(object sender, EventArgs e)
        {
            if (tePsw.Text != "15041959")
            {
                MyLocalizer.XtraMessageBoxShow("Указан неверный пароль.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }
Beispiel #18
0
        private void controlNavigator2_ButtonClick(object sender, NavigatorButtonClickEventArgs e)
        {
            if (e.Button.ButtonType == NavigatorButtonType.Custom)
            {
                e.Handled = true;

                if (GridView.FocusedRowHandle < 0)
                {
                    MyLocalizer.XtraMessageBoxShow("Необходимо указать оборудование.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                DataRowView drv = (DataRowView)(qEquipmentsBindingSource.Current);
                long        id  = Convert.ToInt64(drv.Row["EquipmentID"]);

                if (e.Button.Tag.ToString() == "Visual")
                {
                    InspectionForm form = new InspectionForm(id, Inspection.InspectionType.Visual);
                    form.ShowDialog(this);
                }
                if (e.Button.Tag.ToString() == "FHA")
                {
                    InspectionForm form = new InspectionForm(id, Inspection.InspectionType.FHA);
                    form.ShowDialog(this);
                }
                if (e.Button.Tag.ToString() == "HARG")
                {
                    InspectionForm form = new InspectionForm(id, Inspection.InspectionType.HARG);
                    form.ShowDialog(this);
                }
                if (e.Button.Tag.ToString() == "Warm")
                {
                    InspectionForm form = new InspectionForm(id, Inspection.InspectionType.Warm);
                    form.ShowDialog(this);
                }
                if (e.Button.Tag.ToString() == "Vibro")
                {
                    InspectionForm form = new InspectionForm(id, Inspection.InspectionType.Vibro);
                    form.ShowDialog(this);
                }
                if (e.Button.Tag.ToString() == "Parameter")
                {
                    InspectionForm form = new InspectionForm(id, Inspection.InspectionType.Parameter);
                    form.ShowDialog(this);
                }
                if (e.Button.Tag.ToString() == "Electrical")
                {
                    InspectionForm form = new InspectionForm(id, Inspection.InspectionType.Electrical);
                    form.ShowDialog(this);
                }

                return;
            }
        }
Beispiel #19
0
 private void SwitchDriveTypeSubMenu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     try
     {
         SwitchDriveTypeForm f = new SwitchDriveTypeForm();
         f.ShowDialog(this);
     }
     catch (Exception ex)
     {
         MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #20
0
 private void simpleButton1_Click(object sender, EventArgs e)
 {
     try
     {
         m_bNeedFilter = true;
         FindChecks(-1);
     }
     catch (Exception ex)
     {
         MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #21
0
        public void UpdateRecord()
        {
            if (MainGridView.FocusedRowHandle < 0)
            {
                MyLocalizer.XtraMessageBoxShow("Необходимо указать оборудование.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            DataRowView drv = (DataRowView)(qMainEquipmentsBindingSource.Current);
            long        id  = Convert.ToInt64(drv.Row["EquipmentID"]);

            UpdatePassportData(id);
        }
Beispiel #22
0
 private void bSelect_Click(object sender, EventArgs e)
 {
     if (qEquipmentTypesBindingSource.Current != null)
     {
         m_SelectID        = Convert.ToInt64(((DataRowView)(qEquipmentTypesBindingSource.Current)).Row["EquipmentTypeID"]);
         this.DialogResult = System.Windows.Forms.DialogResult.OK;
         this.Close();
     }
     else
     {
         MyLocalizer.XtraMessageBoxShow("Необходимо выбрать запись", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            m_bSuccess = false;
            SQLiteConnection con = new SQLiteConnection(global::DiarMain.Properties.Settings.Default.diarConnectionString);

            try
            {
                con.Open();
                SQLiteCommand com = new SQLiteCommand(con);

                for (int i = 0; i < m_list.Count; i++)
                {
                    worker.ReportProgress(i);

                    System.Threading.Thread.Sleep(500);

                    if (m_list[i].m_strCommand.IndexOf("FROM FILE") >= 0)
                    {
                        string strFileName = m_list[i].m_strCommand;
                        string strVersion  = m_list[i].m_Version.ToString("#.00");
                        strFileName = AppDomain.CurrentDomain.BaseDirectory + "/ServicePack/" + strVersion.Replace(",", ".") + "/" + strFileName.Replace("FROM FILE", "").Trim();
                        if (!File.Exists(strFileName))
                        {
                            MyLocalizer.XtraMessageBoxShow("Не удалось найти файл " + strFileName, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        FileStream   fs     = File.OpenRead(strFileName);
                        StreamReader srFile = new StreamReader(fs);
                        com.CommandText = srFile.ReadToEnd();
                    }
                    else
                    {
                        com.CommandText = m_list[i].m_strCommand;
                    }
                    com.CommandType = CommandType.Text;
                    com.ExecuteNonQuery();
                }

                worker.ReportProgress(m_list.Count + 1);
                System.Threading.Thread.Sleep(500);

                con.Close();

                m_bSuccess = true;
            }
            catch (SQLiteException ex)
            {
                MyLocalizer.XtraMessageBoxShow("Не удалось подключиться к базе данных. Описание: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Beispiel #24
0
        private void RefreshData()
        {
            try
            {
                m_con.Open();

                SQLiteCommand com = new SQLiteCommand(m_con);
                com.CommandType = CommandType.Text;

                com.CommandText = "SELECT SystemItemResults.InspectionID, SystemItemResults.SystemItemID, SystemItemResults.Result FROM SystemItemResults INNER JOIN Inspections ON " +
                                  "Inspections.InspectionID = SystemItemResults.InspectionID WHERE Inspections.InspectionType = @type AND Inspections.EquipmentID = @eq_id";

                com.Parameters.Clear();
                AddParam(com, "@type", DbType.Int64, (long)m_type);
                AddParam(com, "@eq_id", DbType.Int64, (long)m_EquipmentID);

                m_Data.Clear();
                SQLiteDataReader dr = com.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        long InspectionID = Convert.ToInt64(dr["InspectionID"]);
                        long SystemItemID = Convert.ToInt64(dr["SystemItemID"]);
                        long Result       = Convert.ToInt64(dr["Result"]);

                        if (!m_Data.ContainsKey(InspectionID))
                        {
                            m_Data[InspectionID] = new Dictionary <long, long>();
                        }
                        m_Data[InspectionID][SystemItemID] = Result;
                    }
                }
                dr.Close();

                m_con.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);
            }
        }
Beispiel #25
0
        private void btnReport_Click(object sender, EventArgs e)
        {
            if (MainGridView.FocusedRowHandle < 0)
            {
                MyLocalizer.XtraMessageBoxShow("Необходимо указать оборудование.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            DataRowView drv     = (DataRowView)(qMainEquipmentsBindingSource.Current);
            long        id      = Convert.ToInt64(drv.Row["EquipmentID"]);
            long        kind_id = Convert.ToInt64(drv.Row["EquipmentKindID"]);

            PrintProtocol(id, kind_id);
        }
Beispiel #26
0
 private void MainCheckForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     try
     {
         if (m_bShowCloseMsg && MyLocalizer.XtraMessageBoxShow("Вы действительно хотите выйти из программы?", "Предупреждение", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != System.Windows.Forms.DialogResult.Yes)
         {
             e.Cancel = true;
         }
     }
     catch (Exception ex)
     {
         MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #27
0
 private void SubstationSubMenu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     try
     {
         SubstationForm f = new SubstationForm();
         f.ShowDialog(this);
         m_bNeedFilter = false;
         FindChecks(-1);
     }
     catch (Exception ex)
     {
         MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #28
0
        private void WarmSubMenu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (MainGridView.FocusedRowHandle < 0)
            {
                MyLocalizer.XtraMessageBoxShow("Необходимо указать оборудование.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            DataRowView drv = (DataRowView)(qMainEquipmentsBindingSource.Current);
            long        id  = Convert.ToInt64(drv.Row["EquipmentID"]);

            InspectionForm form = new InspectionForm(id, Inspection.InspectionType.Warm);

            form.ShowDialog(this);
        }
Beispiel #29
0
 private void cbSubject_KeyUp(object sender, KeyEventArgs e)
 {
     try
     {
         if ((e.KeyCode == Keys.Delete || e.KeyCode == Keys.Back) && ((LookUpEdit)sender).Text == "")
         {
             ((LookUpEdit)sender).ClosePopup();
             ((LookUpEdit)sender).EditValue = null;
         }
     }
     catch (Exception ex)
     {
         MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #30
0
        /*void QEquipmentTypes_QEquipmentTypesRowChanging(object sender, DataSetQuery.QEquipmentTypesRowChangeEvent e)
         * {
         *  //throw new NotImplementedException();
         * }*/

        void QEquipmentTypes_QEquipmentTypesRowChanged(object sender, DataSetQuery.QEquipmentTypesRowChangeEvent e)
        {
            if (e.Action == DataRowAction.Add || e.Action == DataRowAction.Change)
            {
                try
                {
                    if (e.Action == DataRowAction.Change && m_bUpdateID)
                    {
                        this.dataSetQuery.QEquipmentTypes.AcceptChanges();
                        m_bUpdateID = false;
                        return;
                    }
                    else
                    {
                        using (var cmdBuilder = new SQLiteCommandBuilder(this.qEquipmentTypesTableAdapter.Adapter)) this.qEquipmentTypesTableAdapter.Adapter.Update(this.dataSetQuery.QEquipmentTypes);
                    }

                    if (e.Action == DataRowAction.Add)
                    {
                        SQLiteConnection connection = new SQLiteConnection(global::DiarMain.Properties.Settings.Default.diarConnectionString);
                        connection.Open();
                        SQLiteCommand com = new SQLiteCommand(connection);
                        com.CommandText = "select seq from sqlite_sequence where name = 'EquipmentTypes'";
                        com.CommandType = CommandType.Text;
                        SQLiteDataReader dr = com.ExecuteReader();

                        long id = 0;
                        while (dr.Read())
                        {
                            id = Convert.ToInt64(dr["seq"]);
                        }
                        dr.Close();
                        connection.Close();

                        m_bUpdateID = true;
                        ((DataRowView)(qEquipmentTypesBindingSource.Current)).Row["EquipmentTypeID"] = id;
                    }
                }
                catch (SQLiteException ex)
                {
                    MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (DBConcurrencyException ex)
                {
                    MyLocalizer.XtraMessageBoxShow(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }