Дипломная работа: Автоматизация обработки заявок ИП "Байбеков"

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
106
{
MessageBox.Show(ex.Message, "DgvInDocsFill()",MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
finally
{
cmd.Connection.Close();
}
}
private void UpdateHeaderText()
{
this.Text = "Входящие документы за период с " +
SessionProperties.begDate.ToShortDateString() + " по " +
SessionProperties.endDate.ToShortDateString();
}
private void DocDelete()
{
var result = MessageBox.Show("Удалить документ?", "Внимание???",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
if (SaveChanges(Date: dtpDate.Value, InDate: dtpInDate.Value, ConstID:
currentConstID, rowStatus: 2))
{
DgvInDocsFill();
RestoreRowIndexPosition();
}
}
}
private void btnExit_Click(object sender, EventArgs e)
{
if (exitCancel)
{
Close();
}
else
{
btnExit.Text = "Esc - Выход";
SwitchMode(2);
}
}
private void btnOk_Click(object sender, EventArgs e)
{
if (rowStatus == 0)
{
DataTable dt = SearchSimilarDoc((int)cboDept.SelectedValue,
(int)cboInDocType.SelectedValue,tbNum.Text);
if (dt.Rows.Count > 0)
{
frmEditInDocsChoosingReplaceDoc _frmEditInDocsChoosingReplaceDoc =
new frmEditInDocsChoosingReplaceDoc(dt);
DialogResult dResult =
_frmEditInDocsChoosingReplaceDoc.ShowDialog();
if (DialogResult.Yes == dResult)
{
rowStatus = 1;
currentConstID = SessionProperties.retInt;
}
if (DialogResult.Cancel == dResult)
{
return;
107
}
}
if (lblImgFile.Text == "" && doc == null)
{
MessageBox.Show("Нет образа отсканированного документа!!!",
"Внимание!!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
if (SaveChanges(dtpDate.Value,dtpInDate.Value, InDocTypeID :
(int)cboInDocType.SelectedValue,ConstID: currentConstID,
Num : tbNum.Text, DeptID : (int)cboDept.SelectedValue, Description :
tbDescription.Text,
ImgFile: lblImgFile.Text, Img: doc, rowStatus: rowStatus))
{
DefaultDate = dtpDate.Value;
DefaultInDate = dtpInDate.Value;
DefaultInDocType = (int)cboInDocType.SelectedValue;
DgvInDocsFill();
RestoreRowIndexPosition();
doc = null;
SwitchMode(2);
}
}
private DataTable SearchSimilarDoc(int DeptID,int InDocTypesID,string DocNum)
{
DataTable resTable = new DataTable();
SqlCommand cmd = new SqlCommand("SELECT * FROM ViewInDocs WHERE DeptID =
@DeptID AND InDocTypesID = @InDocTypesID AND Num = @DocNum ORDER BY Description", new
SqlConnection(SessionProperties.currentConnectionString));
cmd.Parameters.Add("@DeptID", SqlDbType.Int).Value = DeptID;
cmd.Parameters.Add("@InDocTypesID", SqlDbType.Int).Value = InDocTypesID;
cmd.Parameters.Add("@DocNum", SqlDbType.NVarChar).Value = DocNum;
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(resTable);
return resTable;
}
private void RestoreRowIndexPosition()
{
try
{
if (dgvInDocs.Rows.Count > 0)
{
DataRow[] searchedRows =
((DataTable)dgvInDocs.DataSource).Select("ConstID = " + currentConstID.ToString());
int rowIndex;
if (searchedRows.Length > 0)
{
rowIndex = tblInDocs.Rows.IndexOf(searchedRows[0]);
}
else
{
rowIndex = (dgvRowIndex >= dgvInDocs.Rows.Count) ?
dgvInDocs.Rows.Count - 1 : dgvRowIndex;
}
if (rowIndex > dgvInDocs.Rows.Count - 1)
{
dgvInDocs.CurrentCell = dgvInDocs[0, 0];
}
else
dgvInDocs.CurrentCell = dgvInDocs[0, rowIndex];
}
}
108
catch (Exception ex)
{
MessageBox.Show(ex.Message,
"RestoreRowIndexPosition()",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
private void dgvInDocs_CellMouseDoubleClick(object sender,
DataGridViewCellMouseEventArgs e)
{
if (rowStatus == -1)//режим выбора
{
DataRow row =
((DataRowView)dgvInDocs.Rows[e.RowIndex].DataBoundItem).Row;//строка из привязанной
таблицы
SessionProperties.retInt = (int)row["ConstID"];//возврат
(сохранение в статическом объекте) значения из формы
SessionProperties.retString = (string)row["FullName"];
EventHandler<EventArgs> handler = RaiseInDocSelected;
// Event will be null if there are no subscribers
if (handler != null)
{
// Use the () operator to raise the event.
handler(this, e);
}
Close();
return;
}
if (e.RowIndex >= 0)
{
dgvRowIndex = dgvInDocs.CurrentRow.Index;
rowStatus = 1;
tsbDocEdit_Click(null, null);
//SwitchMode(1);
}
}
private void dgvInDocs_RowEnter(object sender, DataGridViewCellEventArgs
e)
{
ControlsRefresh(e);
}
private void tsbDocNew_Click(object sender, EventArgs e)
{
if (rights.Contains("a"))
SwitchMode(0);
else
{
MessageBox.Show("У вас нет прав на добавление документов!!!",
"Обратитесь к администратору!!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
private void tsbDocEdit_Click(object sender, EventArgs e)
{
if (rights.Contains("e"))
{
SwitchMode(1);
}
else
{
MessageBox.Show("У вас нет прав на редактирование документов!!!",
"Обратитесь к администратору!!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
109
}
}
private void btnImage_Click(object sender, EventArgs e)
{
OpenFileDialog ofdInDoc = new OpenFileDialog();
string val = lblImgFile.Text;
if (val == "")
{
val = GetDefaultSetting.Get("DefaultInDocImgPath");
if (val == "") { return; }
}
ofdInDoc.InitialDirectory = val;
val = GetDefaultSetting.Get("DefaultInDocImgFilter");
if (val == "") { return; }
ofdInDoc.Filter = val;
if (ofdInDoc.ShowDialog() == DialogResult.OK)
{
lblImgFile.Text = ofdInDoc.FileName;
FillValueAfterOpenFileDialog(ofdInDoc.FileName);
}
Environment.CurrentDirectory = Application.StartupPath;
}
private void tsbSetting_Click(object sender, EventArgs e)
{
frmPeriodSelector fps = new frmPeriodSelector();
//fps.Owner = this;
//fps.MdiParent = this.MdiParent;
if (fps.ShowDialog() == DialogResult.OK)
{
DgvInDocsFill();
UpdateHeaderText();
}
}
private void tsbDocDelete_Click(object sender, EventArgs e)
{
if (rights.Contains("d"))
DocDelete();
else
{
MessageBox.Show("У вас нет прав на удаление документов!!!",
"Обратитесь к администратору!!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
private void dgvInDocs_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Enter:
e.SuppressKeyPress = true;
if (dgvInDocs.CurrentRow != null)
{
DataRow row =
((DataRowView)dgvInDocs.CurrentRow.DataBoundItem).Row;
SwitchMode(1);
}
break;
case Keys.Insert:
SwitchMode(0);
break;
case Keys.Delete:
110
dgvRowIndex = dgvInDocs.CurrentRow.Index;
DocDelete();
break;
}
if (e.Control && Keys.O == e.KeyCode)
{
if (dgvInDocs.CurrentRow != null)
OpenDoc((int)dgvInDocs.CurrentRow.Cells["ID"].Value,
(int)dgvInDocs.CurrentRow.Cells["constID"].Value);
}
}
private void tsmiDocNew_Click(object sender, EventArgs e)
{
//SwitchMode(0);
tsbDocNew_Click(null, null);
}
private void tsmiDocEdit_Click(object sender, EventArgs e)
{
//SwitchMode(1);
tsbDocEdit_Click(null, null);
}
private void tsmiDocDelete_Click(object sender, EventArgs e)
{
tsbDocDelete_Click(null, null);
//DocDelete();
}
private void frmEditInDocs_FormClosed(object sender, FormClosedEventArgs
e)
{
GLOBAL2.Properties.Settings.Default.frmEditInDocsLocation =
this.Location;
GLOBAL2.Properties.Settings.Default.Save();
}
//
//Форма настройки поиска (аля фильтр)
//
private void tsbSettings_Click(object sender, EventArgs e)
{
if (FrmEditInDocsSettings != null)
if (FrmEditInDocsSettings.IsDisposed == true)
FrmEditInDocsSettings = null;
if (FrmEditInDocsSettings == null)
{
FrmEditInDocsSettings = new frmEditInDocsSettings();
FrmEditInDocsSettings.invokeSearch = Search;
FrmEditInDocsSettings.Owner = this.Owner;
FrmEditInDocsSettings.MdiParent = this.MdiParent;
FrmEditInDocsSettings.dtDept = ((DataTable)cboDept.DataSource).Copy();
FrmEditInDocsSettings.dtTypeDoc =
((DataTable)cboInDocType.DataSource).Copy();
FrmEditInDocsSettings.frmEIDs = this;
FrmEditInDocsSettings.Show();
if (currentFilter != null)
{
FrmEditInDocsSettings.SetControlValue(currentFilter.Dept,
currentFilter.TypeDoc, currentFilter.NumDoc,
currentFilter.InNumDoc, currentFilter.DateDoc,
currentFilter.InDateDoc, currentFilter.Description);
}
}
Источник: https://baza.diplomsite.ru/previewfile/1876