Exemplo n.º 1
0
        private void btnbtnAddResponsibility_Click(object sender, EventArgs e)
        {
            if (!Edit)
            {
                if (string.IsNullOrWhiteSpace(rtbFunctionName.Text))
                {
                    return;
                }

                if (AdminFunctionsEdit.IsFunctionAlreadyAdded(AdminFunctionsEdit.CurrentDepartmentID, rtbFunctionName.Text, rtbFunctionDescription.Text))
                {
                    Infinium.LightMessageBox.Show(ref TopForm, false, "Обязанность уже существует", "Добавление обязанности");
                    return;
                }
                AdminFunctionsEdit.AddFunction(AdminFunctionsEdit.CurrentDepartmentID, rtbFunctionName.Text, rtbFunctionDescription.Text);
            }
            else
            {
                if (string.IsNullOrWhiteSpace(rtbFunctionName.Text))
                {
                    return;
                }

                AdminFunctionsEdit.EditFunction(FunctionID, rtbFunctionName.Text, rtbFunctionDescription.Text);
            }
            AdminFunctionsEdit.Save();

            this.Close();
        }
        private void btnDeleteFunction_Click(object sender, EventArgs e)
        {
            //bool OKCancel = Infinium.LightMessageBox.Show(ref TopForm, true,
            //        "Функция временно недоступна",
            //        "Открепление обязанности от сотрудника");
            //if (!OKCancel)
            //    return;
            if (dgvAllFunctions.SelectedRows.Count != 0)
            {
                bool OKCancel = Infinium.LightMessageBox.Show(ref TopForm, true,
                                                              "Удалить обязаность? Запись будет удалена безвозвратно.",
                                                              "Удаление обязаности");

                if (OKCancel)
                {
                    int FunctionID = Convert.ToInt32(dgvAllFunctions.SelectedRows[0].Cells["FunctionID"].Value);
                    AdminFunctionsEdit.DeleteFunction(FunctionID);
                    AdminFunctionsEdit.Save();
                }
            }
        }