private void PartnersPFCopy() { if (grdData.CurrentRow == null) { return; } if (!oPartnerCur.ID.HasValue) { return; } if (!grdData.IsCheckerShow || grdData.MarkedCount == 0) { RFMMessage.MessageBoxError("Нет отмеченных партнеров..."); return; } int nPartnerID = (int)oPartnerCur.ID; oPartnerCur.ReFillOne(nPartnerID); if ((oPartnerCur.PF_BillName == null || oPartnerCur.PF_BillName.Trim().Length == 0) && oPartnerCur.PF_BillCopiesCount == 0 && (oPartnerCur.PF_FactureName == null || oPartnerCur.PF_FactureName.Trim().Length == 0) && oPartnerCur.PF_FactureCopiesCount == 0 && (oPartnerCur.PF_PayBillName == null || oPartnerCur.PF_PayBillName.Trim().Length == 0) && oPartnerCur.PF_PayBillCopiesCount == 0) { RFMMessage.MessageBoxError("Для текущего партнера нет данных о специальных печатных формах..."); return; } Partner oPartnerForCopy = new Partner(); PartnerPrepareIDList(oPartnerForCopy, true); if (oPartnerForCopy.IDList != null && oPartnerForCopy.IDList.Length > 0) { string sText = "," + oPartnerForCopy.IDList + ","; if (sText.Contains("," + nPartnerID.ToString().Trim() + ",")) { sText = sText.Replace("," + nPartnerID.ToString().Trim() + ",", ","); oPartnerForCopy.IDList = RFMUtilities.NormalizeList(sText); } if (!oPartnerForCopy.FillData() || oPartnerForCopy.MainTable == null || oPartnerForCopy.MainTable.Rows.Count == 0) { RFMMessage.MessageBoxError("Нет данных об отмеченных партнерах..."); return; } if (RFMMessage.MessageBoxYesNo("Выполнить копирование данных о специальных печатных формах и нестандартном количестве копий формируемых документов текущего партнера\n" + "\"" + oPartnerCur.Name + "\"\n" + "для всех отмеченных партнеров (" + oPartnerForCopy.MainTable.Rows.Count.ToString().Trim() + ")?\n\n" + "ВНИМАНИЕ!\n" + "Существующие данные о печатных формах и количестве копий для отмеченных партнеров, если таковые имеются, будут полностью заменены на данные текущего партнера!") == DialogResult.Yes) { if (oPartnerForCopy.CopyDataPartnersPF(nPartnerID, oPartnerForCopy.IDList)) { grdData_Restore(); } } } else { RFMMessage.MessageBoxError("Нет данных об отмеченных партнерах..."); return; } }
private void btnSave_Click(object sender, EventArgs e) { if (grdData.DataSource == null || grdData.Rows.Count == 0) { RFMMessage.MessageBoxError("Не получен список доступных поддонов..."); return; } // проверяем отмеченные контейнеры int nMarkedCnt = 0; foreach (DataRow r in dt.Rows) { if (!Convert.IsDBNull(r["IsMarked"]) && Convert.ToBoolean(r["IsMarked"])) { nMarkedCnt++; } } if (nMarkedCnt == 0) { RFMMessage.MessageBoxError("Не отмечено ни одного поддона..."); return; } if (chkForOutput.Checked) { // в отгрузку if (cboCellOutput.SelectedValue == null || cboCellOutput.SelectedIndex < 0) { RFMMessage.MessageBoxError("Не выбрана ячейка отгрузки..."); return; } Cell oCellOutputTemp = new Cell(); oCellOutputTemp.ID = (int)cboCellOutput.SelectedValue; oCellOutputTemp.FillData(); if (oCellOutputTemp.ErrorNumber != 0 || oCellOutputTemp.MainTable == null || oCellOutputTemp.MainTable.Rows.Count != 1) { RFMMessage.MessageBoxError("Ошибка при получении данных о ячейке отгрузки..."); return; } nCellFinishID = Convert.ToInt32(oCellOutputTemp.MainTable.Rows[0]["ID"]); sCellFinishAddress = oCellOutputTemp.MainTable.Rows[0]["Address"].ToString(); if (RFMMessage.MessageBoxYesNo("Создать операции транспортировки в ячейку отгрузки " + sCellFinishAddress + " для " + RFMPublic.RFMUtilities.Declen(nMarkedCnt, "поддона", "поддонов", "поддонов") + "?") != DialogResult.Yes) { return; } } else { if (oCellPicking.MainTable == null || oCellPicking.MainTable.Rows.Count == 0) { RFMMessage.MessageBoxError("Не определена ячейка пикинга для товара."); return; } nCellFinishID = Convert.ToInt32(oCellPicking.MainTable.Rows[0]["ID"]); sCellFinishAddress = oCellPicking.MainTable.Rows[0]["Address"].ToString(); // в пикинг if (RFMMessage.MessageBoxYesNo("Создать операции транспортировки в ячейку пикинга " + sCellFinishAddress + " для " + RFMPublic.RFMUtilities.Declen(nMarkedCnt, "поддона", "поддонов", "поддонов") + "?") != DialogResult.Yes) { return; } } // создаем транспортировки последовательно int nFrameID; int nOK = 0; string sNote = txtNoteManual.Text.Trim(); foreach (DataRow r in dt.Rows) { if (!Convert.IsDBNull(r["IsMarked"]) && Convert.ToBoolean(r["IsMarked"])) { oTraffic.ClearError(); nFrameID = Convert.ToInt32(r["FrameID"]); oTraffic.CreateManualDirect(nFrameID, (int)nCellFinishID, nPriority, sNote); if (oTraffic.ErrorNumber == 0) { nOK++; } } } if (nOK > 0) { RFMMessage.MessageBoxInfo("Создано " + RFMUtilities.Declen(nOK, "задание", "задания", "заданий") + " на транспортировку поддонов в " + ((chkForOutput.Checked) ? "зону отгрузки" : "пикинг") + "."); DialogResult = DialogResult.Yes; Dispose(); } else { RFMMessage.MessageBoxError("Задания на транспортировку поддонов в " + ((chkForOutput.Checked) ? "зону отгрузки" : "пикинг") + " не созданы."); } }
private void PartnersGoodsCopy() { if (grdData.CurrentRow == null) { return; } if (!oPartnerCur.ID.HasValue) { return; } if (!grdData.IsCheckerShow || grdData.MarkedCount == 0) { RFMMessage.MessageBoxError("Нет отмеченных партнеров..."); return; } int nPartnerID = (int)oPartnerCur.ID; if (!oPartnerCur.FillTablePartnersGoods(nPartnerID) || oPartnerCur.TablePartnersGoods == null || oPartnerCur.TablePartnersGoods.Rows.Count == 0) { RFMMessage.MessageBoxError("Для текущего партнера нет спец.данных о товарах..."); return; } Partner oPartnerForCopy = new Partner(); PartnerPrepareIDList(oPartnerForCopy, true); if (oPartnerForCopy.IDList != null && oPartnerForCopy.IDList.Length > 0) { string sText = "," + oPartnerForCopy.IDList + ","; if (sText.Contains("," + nPartnerID.ToString().Trim() + ",")) { sText = sText.Replace("," + nPartnerID.ToString().Trim() + ",", ","); oPartnerForCopy.IDList = RFMUtilities.NormalizeList(sText); } if (!oPartnerForCopy.FillData() || oPartnerForCopy.MainTable == null || oPartnerForCopy.MainTable.Rows.Count == 0) { RFMMessage.MessageBoxError("Нет данных об отмеченных партнерах..."); return; } if (RFMMessage.MessageBoxYesNo("Выполнить копирование спец.данных о товарах текущего партнера\n" + "\"" + oPartnerCur.Name + "\"\n" + "для всех отмеченных партнеров (" + oPartnerForCopy.MainTable.Rows.Count.ToString().Trim() + ")?\n\n" + "ВНИМАНИЕ!\n" + "Существующие спец.данные о товарах для отмеченных партнеров, если таковые имеются, будут удалены и полностью заменены на спец.данные о товарах текущего партнера!") == DialogResult.Yes) { if (oPartnerForCopy.CopyTablePartnersGoods(nPartnerID, oPartnerForCopy.IDList)) { grdData_Restore(); } } } else { RFMMessage.MessageBoxError("Нет данных об отмеченных партнерах..."); return; } }
private void GroupHeader1_Format(object sender, EventArgs e) { txtDateInvoice.Text = RFMUtilities.DateToTxt(DateTime.Now.Date); }
private void GroupFooter1_Format(object sender, EventArgs e) { txtGroupFooterAdd.Text = txtGroupFooterAdd.Tag.ToString().Replace("#", RFMPublic.RFMUtilities.Declen(_nCnt, "номер", "номера", "номеров") + " записей"); if ((int)Math.Round(_nOutputDocumentBox, 0) != 0) { txtGroupFooterBoxes.Text = txtGroupFooterBoxes.Tag + RFMPublic.RFMUtilities.ValToTxt((int)Math.Round(_nOutputDocumentBox, 0)); } else { txtGroupFooterBoxes.Text = ""; } txtGroupFooterNetto.Text = txtGroupFooterNetto.Tag + _nOutputDocumentNetto.ToString("# ### ##0.000"); txtGroupFooterNettoText.Text = txtGroupFooterNettoText.Tag + "(" + ((int)Math.Floor(_nOutputDocumentNetto)).ToString("# ### ##0").Trim() + " кг " + ((int)((_nOutputDocumentNetto - Math.Floor(_nOutputDocumentNetto)) * 1000)).ToString("000") + " г)"; txtGroupFooterBrutto.Text = txtGroupFooterBrutto.Tag + _nOutputDocumentBrutto.ToString("# ### ##0.000"); txtGroupFooterBruttoText.Text = txtGroupFooterBruttoText.Tag + "(" + ((int)Math.Floor(_nOutputDocumentBrutto)).ToString("# ### ##0").Trim() + " кг " + ((int)((_nOutputDocumentBrutto - Math.Floor(_nOutputDocumentBrutto)) * 1000)).ToString("000") + " г)"; if (_nCurrencyID.ToString() == _sRubID) { txtGroupFooterAmount.Text = RFMUtilities.ValToRub(_nAmount); } else { txtGroupFooterAmount.Text = RFMUtilities.ValToRub(_nAmount, _sCurrencyAlias); } /* * txtGroupFooterVatSum.Text = _nVatAllSum.ToString("### ### ###0.00"); * txtGroupFooterNoVatSum.Text = _nNoVatAllSum.ToString("### ### ###0.00"); * * if (_nVat1Rate > 0) * { * txtGroupFooterLabelVat1Sum.Text = txtGroupFooterLabelVat1Sum.Tag.ToString().Replace("#", _nVat1Rate.ToString("######").Trim()); * txtGroupFooterLabelNoVat1Sum.Text = txtGroupFooterLabelNoVat1Sum.Tag.ToString().Replace("#", _nVat1Rate.ToString("######").Trim()); * txtGroupFooterVat1Sum.Text = _nVat1Sum.ToString("### ### ###0.00"); * txtGroupFooterNoVat1Sum.Text = _nNoVat1Sum.ToString("### ### ###0.00"); * } * else * { * txtGroupFooterLabelVat1Sum.Text = * txtGroupFooterLabelNoVat1Sum.Text = * txtGroupFooterVat1Sum.Text = * txtGroupFooterNoVat1Sum.Text = * ""; * } * * if (_nVat2Rate > 0) * { * txtGroupFooterLabelVat2Sum.Text = txtGroupFooterLabelVat2Sum.Tag.ToString().Replace("#", _nVat2Rate.ToString("######").Trim()); * txtGroupFooterLabelNoVat2Sum.Text = txtGroupFooterLabelNoVat2Sum.Tag.ToString().Replace("#", _nVat2Rate.ToString("######").Trim()); * txtGroupFooterVat2Sum.Text = _nVat2Sum.ToString("### ### ###0.00"); * txtGroupFooterNoVat2Sum.Text = _nNoVat2Sum.ToString("### ### ###0.00"); * } * else * { * txtGroupFooterLabelVat2Sum.Text = * txtGroupFooterLabelNoVat2Sum.Text = * txtGroupFooterVat2Sum.Text = * txtGroupFooterNoVat2Sum.Text = * ""; * } */ }
private void btnGo_Click(object sender, EventArgs e) { // возвращаем код/список кодов заказов в родительскую форму string _SelectedInputsDocumentsIDList = null; int? _SelectedInputDocumentID = null; string _SelectedInputsDocumentsText = ""; if (grdInputsDocuments.Rows.Count > 0) { if (useCheck && grdInputsDocuments.IsCheckerShow) { // список ID _SelectedInputsDocumentsIDList = ""; _SelectedInputsDocumentsText = ""; DataView dMarked = new DataView(oInputDocumentList.MainTable); dMarked.RowFilter = "IsMarked = true"; dMarked.Sort = grdInputsDocuments.GridSource.Sort; int i = 0; foreach (DataRowView r in dMarked) { if (!Convert.IsDBNull(r["ID"])) { _SelectedInputsDocumentsIDList += r["ID"].ToString() + ","; if (i < nFirstCntRecords) { _SelectedInputsDocumentsText += Convert.ToDateTime(r["DateInput"]).ToString("dd.MM.yyyy") + " " + r["PartnerTargetName"].ToString() + ", "; } else { if (i == nFirstCntRecords) { _SelectedInputsDocumentsText += "..."; } } i++; } } if (_SelectedInputsDocumentsIDList.Length == 0) { // нет отметок - берем текущую запись if (grdInputsDocuments.CurrentRow != null) { _SelectedInputsDocumentsIDList = grdInputsDocuments.CurrentRow.Cells["grcInputsDocuments_ID"].Value.ToString() + ","; _SelectedInputsDocumentsText = grdInputsDocuments.CurrentRow.Cells["grcInputsDocuments_DateInput"].Value.ToString().Substring(0, 10) + " " + grdInputsDocuments.CurrentRow.Cells["grcInputsDocuments_PartnerTargetName"].Value.ToString().Trim(); } } // приводим наборное текстовое поле к виду: (5) раз, два, три, ... if (_SelectedInputsDocumentsIDList.Length == 0) { _SelectedInputsDocumentsIDList = null; _SelectedInputsDocumentsText = ""; } else { _SelectedInputsDocumentsText = _SelectedInputsDocumentsText.Trim(); if (_SelectedInputsDocumentsText.Substring(_SelectedInputsDocumentsText.Length - 1, 1) == ",") { _SelectedInputsDocumentsText = _SelectedInputsDocumentsText.Substring(0, _SelectedInputsDocumentsText.Length - 1); } _SelectedInputsDocumentsText = "(" + RFMUtilities.Occurs(_SelectedInputsDocumentsIDList, ",").ToString() + "): " + _SelectedInputsDocumentsText; } RFMUtilities.SetFormField(parentForm, "_SelectedInputsDocumentsIDList", _SelectedInputsDocumentsIDList); RFMUtilities.SetFormField(parentForm, "_SelectedInputsDocumentsText", _SelectedInputsDocumentsText); } else { // ID текущей строки if (grdInputsDocuments.CurrentRow != null) { _SelectedInputDocumentID = Convert.ToInt32(grdInputsDocuments.CurrentRow.Cells["grcInputsDocuments_ID"].Value); _SelectedInputsDocumentsText = grdInputsDocuments.CurrentRow.Cells["grcInputsDocuments_DateInput"].Value.ToString().Substring(0, 10) + " " + grdInputsDocuments.CurrentRow.Cells["grcInputsDocuments_PartnerTargetName"].Value.ToString().Trim(); } RFMUtilities.SetFormField(parentForm, "_SelectedInputDocumentID", _SelectedInputDocumentID); RFMUtilities.SetFormField(parentForm, "_SelectedInputsDocumentsText", _SelectedInputsDocumentsText); } } else { RFMMessage.MessageBoxInfo("Не выбрано ни одного приходного документа..."); } DialogResult = DialogResult.Yes; Dispose(); }
private void SetStartTerms() { // начальные условия if (oInputDocument != null) { // даты диапазона можно менять if (oInputDocument.FilterDateBeg != null) { dtrDates.dtpBegDate.Value = Convert.ToDateTime(oInputDocument.FilterDateBeg); } if (oInputDocument.FilterDateEnd != null) { dtrDates.dtpEndDate.Value = Convert.ToDateTime(oInputDocument.FilterDateEnd); } // другие условия менять нельзя /* * if (oInputDocument.FilterDateInput != null) * { * dtrDates.dtpBegDate.Value = * dtrDates.dtpEndDate.Value = * Convert.ToDateTime(oInputDocument.FilterDateInput); * dtrDates.Enabled = false; * } */ if (oInputDocument.FilterDeliveryNeed != null) { if ((bool)oInputDocument.FilterDeliveryNeed) { optDeliveryNeed.Checked = true; } else { optDeliveryNeedNot.Checked = true; } pnlDeliveryNeed.Enabled = false; } if (oInputDocument.FilterOwnersList != null) { ucSelectRecordID_Owners.LstMarked = oInputDocument.FilterOwnersList.ToString(); ucSelectRecordID_Owners.Enabled = false; } if (oInputDocument.FilterPartnersSourceList != null) { ucSelectRecordID_PartnersSource.LstMarked = oInputDocument.FilterPartnersSourceList.ToString(); ucSelectRecordID_PartnersSource.Enabled = false; } if (oInputDocument.FilterPartnersTargetList != null) { ucSelectRecordID_PartnersTarget.LstMarked = oInputDocument.FilterPartnersTargetList.ToString(); ucSelectRecordID_PartnersTarget.Enabled = false; } if (oInputDocument.FilterIsConfirmed != null) { if ((bool)oInputDocument.FilterIsConfirmed) { optInputsDocumentsIsConfirmed.Checked = true; } else { optInputsDocumentsIsConfirmedNot.Checked = true; } pnlInputsDocumentsIsConfirmed.Enabled = false; } if (oInputDocument.FilterTripExists != null) { if ((bool)oInputDocument.FilterTripExists) { optTripExists.Checked = true; } else { optTripExistsNot.Checked = true; } pnlTripExists.Enabled = false; } if (oInputDocument.FilterTripsList != null) { if (RFMUtilities.Occurs(RFMUtilities.NormalizeList(oInputDocument.FilterTripsList), ",") == 0 && oInputDocument.FilterTripsList != "") { try { numTripID.Value = Convert.ToInt32(RFMUtilities.NormalizeList(oInputDocument.FilterTripsList)); } finally { } } numTripID.Enabled = lblAliasContext.Enabled = false; } if (oInputDocument.FilterPackingsList != null) { sSelectedPackingsIDList = oInputDocument.FilterPackingsList.ToString(); pnlPackings.Enabled = false; } if (oInputDocument.FilterHostsList != null) { ucSelectRecordID_Hosts.LstMarked = oInputDocument.FilterHostsList.ToString(); ucSelectRecordID_Hosts.Enabled = false; } if (nUserHostID.HasValue) { ucSelectRecordID_Hosts.LstMarked = nUserHostID.ToString(); } } }
private void GroupFooter1_Format(object sender, EventArgs e) { if (_bFactoring) { barcode1.Visible = barcode2.Visible = true; barcode1.Text = Utilities.GetCRCBarCode_128A(Utilities.GetAlfaBankBarCode_128A42(sPayeeINN, sPayerINN, nSum, dDate)); barcode2.Text = Utilities.GetCRCBarCode_128A(Utilities.GetAlfaBankBarCode_128A40(_sFactureNumber, sIsoCode)); } else { barcode1.Visible = barcode2.Visible = false; } /* * txtGroupFooterAdd.Text = txtGroupFooterAdd.Tag.ToString().Replace("#", _nCnt.ToString().Trim() + " (" + RFMPublic.RFMUtilities.ValToTxt(_nCnt) + ")"); * * txtGroupFooterContractNumber.Text = _sContractNumberText; * * if ((int)Math.Round(_nOutputDocumentBox, 0) != 0) * { * txtGroupFooterBoxes.Text = txtGroupFooterBoxes.Tag + RFMPublic.RFMUtilities.ValToTxt((int)Math.Round(_nOutputDocumentBox, 0)); * } * else * { * txtGroupFooterBoxes.Text = ""; * } * * txtGroupFooterNettoText.Text = _nOutputDocumentNetto.ToString("# ### ##0.000") + * " (" + ((int)Math.Floor(_nOutputDocumentNetto)).ToString("# ### ##0").Trim() + " êã " + * ((int)((_nOutputDocumentNetto - Math.Floor(_nOutputDocumentNetto)) * 1000)).ToString("000") + " ã)"; * * txtGroupFooterBruttoText.Text = _nOutputDocumentBrutto.ToString("# ### ##0.000") + * " (" + ((int)Math.Floor(_nOutputDocumentBrutto)).ToString("# ### ##0").Trim() + " êã " + * ((int)((_nOutputDocumentBrutto - Math.Floor(_nOutputDocumentBrutto)) * 1000)).ToString("000") + " ã)"; */ if (_nCurrencyID.ToString() == _sRubID) { txtGroupFooterAmount.Text = RFMUtilities.ValToRub(_nAmount); } else { txtGroupFooterAmount.Text = RFMUtilities.ValToRub(_nAmount, _sCurrencyAlias); } /* * txtGroupFooterVatSum.Text = _nVatAllSum.ToString("### ### ###0.00"); * txtGroupFooterNoVatSum.Text = _nNoVatAllSum.ToString("### ### ###0.00"); * * if (_nVat1Rate > 0) * { * txtGroupFooterLabelVat1Sum.Text = txtGroupFooterLabelVat1Sum.Tag.ToString().Replace("#", _nVat1Rate.ToString("######").Trim()); * txtGroupFooterLabelNoVat1Sum.Text = txtGroupFooterLabelNoVat1Sum.Tag.ToString().Replace("#", _nVat1Rate.ToString("######").Trim()); * txtGroupFooterVat1Sum.Text = _nVat1Sum.ToString("### ### ###0.00"); * txtGroupFooterNoVat1Sum.Text = _nNoVat1Sum.ToString("### ### ###0.00"); * } * else * { * txtGroupFooterLabelVat1Sum.Text = * txtGroupFooterLabelNoVat1Sum.Text = * txtGroupFooterVat1Sum.Text = * txtGroupFooterNoVat1Sum.Text = * ""; * } * * if (_nVat2Rate > 0) * { * txtGroupFooterLabelVat2Sum.Text = txtGroupFooterLabelVat2Sum.Tag.ToString().Replace("#", _nVat2Rate.ToString("######").Trim()); * txtGroupFooterLabelNoVat2Sum.Text = txtGroupFooterLabelNoVat2Sum.Tag.ToString().Replace("#", _nVat2Rate.ToString("######").Trim()); * txtGroupFooterVat2Sum.Text = _nVat2Sum.ToString("### ### ###0.00"); * txtGroupFooterNoVat2Sum.Text = _nNoVat2Sum.ToString("### ### ###0.00"); * } * else * { * txtGroupFooterLabelVat2Sum.Text = * txtGroupFooterLabelNoVat2Sum.Text = * txtGroupFooterVat2Sum.Text = * txtGroupFooterNoVat2Sum.Text = * ""; * } */ }
public bool Save(DataTable tableFillingsInWayBill, DataTable tableTripsInWayBill) { // присоединенные таблицы: заправки и рейсы try { _Connect.Open(); } catch (Exception ex) { _ErrorNumber = -1; _ErrorStr = "Ошибка при соединении с сервером...\n" + ex.Message; RFMMessage.MessageBoxError(_ErrorStr); return(false); } if (tableFillingsInWayBill != null) { RFMUtilities.DataTableToTempTable(tableFillingsInWayBill, "#FillingsInWayBill", _Connect); } if (tableTripsInWayBill != null) { RFMUtilities.DataTableToTempTable(tableTripsInWayBill, "#TripsInWayBill", _Connect); } string _sqlCommand = "execute up_WayBillsSave @nWayBillID output, " + "@cBillNumber, " + "@dDateWayBeg, @dDateWayEnd, " + "@nCarID, @nDriverEmployeeID, " + "@cDriverOther, @cReason, " + "@nSpeedometerDataBeg, @nSpeedometerDataEnd, " + "@nFuelDataBeg, @nFuelDataEnd, " + "@nFuelFreezerDataBeg, @nFuelFreezerDataEnd, " + "@nFuelQntFilled, " + "@nFreezerDurationMinutes, " + "@cNote, " + "@nUserCreateID, " + "@nError output, @cErrorText output"; SqlCommand _oCommand = new SqlCommand(_sqlCommand, _Connect); #region up_WayBillsSave parameters SqlParameter _oParameter = _oCommand.Parameters.Add("@nWayBillID", SqlDbType.Int); _oParameter.Direction = ParameterDirection.InputOutput; if (_ID.HasValue) { _oParameter.Value = _ID; } else { _oParameter.Value = 0; } _oParameter = _oCommand.Parameters.Add("@cBillNumber", SqlDbType.VarChar); if (_BillNumber != null) { _oParameter.Value = _BillNumber; } else { _oParameter.Value = DBNull.Value; } _oParameter = _oCommand.Parameters.Add("@nCarID", SqlDbType.Int); _oParameter.Value = _CarID; _oParameter = _oCommand.Parameters.Add("@dDateWayBeg", SqlDbType.SmallDateTime); _oParameter.Value = _DateWayBeg; _oParameter = _oCommand.Parameters.Add("@dDateWayEnd", SqlDbType.SmallDateTime); _oParameter.Value = _DateWayEnd; _oParameter = _oCommand.Parameters.Add("@nDriverEmployeeID", SqlDbType.Int); _oParameter.Value = _DriverEmployeeID; _oParameter = _oCommand.Parameters.Add("@cDriverOther", SqlDbType.VarChar); _oParameter.Value = _DriverOther; _oParameter = _oCommand.Parameters.Add("@cReason", SqlDbType.VarChar); _oParameter.Value = _Reason; _oParameter = _oCommand.Parameters.Add("@nSpeedometerDataBeg", SqlDbType.Int); if (_SpeedometerDataBeg.HasValue) { _oParameter.Value = _SpeedometerDataBeg; } else { _oParameter.Value = DBNull.Value; } _oParameter = _oCommand.Parameters.Add("@nSpeedometerDataEnd", SqlDbType.Int); if (_SpeedometerDataEnd.HasValue) { _oParameter.Value = _SpeedometerDataEnd; } else { _oParameter.Value = DBNull.Value; } _oParameter = _oCommand.Parameters.Add("@nFuelDataBeg", SqlDbType.Decimal); _oParameter.Precision = 6; _oParameter.Scale = 1; if (_FuelDataBeg.HasValue) { _oParameter.Value = _FuelDataBeg; } else { _oParameter.Value = DBNull.Value; } _oParameter = _oCommand.Parameters.Add("@nFuelDataEnd", SqlDbType.Decimal); _oParameter.Precision = 6; _oParameter.Scale = 1; if (_FuelDataEnd.HasValue) { _oParameter.Value = _FuelDataEnd; } else { _oParameter.Value = DBNull.Value; } _oParameter = _oCommand.Parameters.Add("@nFuelFreezerDataBeg", SqlDbType.Decimal); _oParameter.Precision = 6; _oParameter.Scale = 1; if (_FuelFreezerDataBeg.HasValue) { _oParameter.Value = _FuelFreezerDataBeg; } else { _oParameter.Value = DBNull.Value; } _oParameter = _oCommand.Parameters.Add("@nFuelFreezerDataEnd", SqlDbType.Decimal); _oParameter.Precision = 6; _oParameter.Scale = 1; if (_FuelFreezerDataEnd.HasValue) { _oParameter.Value = _FuelFreezerDataEnd; } else { _oParameter.Value = DBNull.Value; } _oParameter = _oCommand.Parameters.Add("@nFuelQntFilled", SqlDbType.Decimal); _oParameter.Precision = 6; _oParameter.Scale = 1; if (_FuelQntFilled.HasValue) { _oParameter.Value = _FuelQntFilled; } else { _oParameter.Value = DBNull.Value; } _oParameter = _oCommand.Parameters.Add("@nFreezerDurationMinutes", SqlDbType.Int); if (_FreezerDurationMinutes.HasValue) { _oParameter.Value = _FreezerDurationMinutes; } else { _oParameter.Value = DBNull.Value; } _oParameter = _oCommand.Parameters.Add("@cNote", SqlDbType.VarChar); _oParameter.Value = _Note; _oParameter = _oCommand.Parameters.Add("@nUserCreateID", SqlDbType.Int); if (_UserCreateID.HasValue) { _oParameter.Value = _UserCreateID; } else { _oParameter.Value = DBNull.Value; } _oParameter = _oCommand.Parameters.Add("@nError", SqlDbType.Int); _oParameter.Direction = ParameterDirection.InputOutput; _oParameter.Value = 0; _oParameter = _oCommand.Parameters.Add("@cErrorText", SqlDbType.VarChar, 200); _oParameter.Direction = ParameterDirection.InputOutput; _oParameter.Value = ""; #endregion try { _oCommand.ExecuteScalar(); } catch (Exception ex) { _ErrorNumber = -10; _ErrorStr = "Ошибка при сохранении путевого листа...\r\n" + ex.Message; RFMMessage.MessageBoxError(_ErrorStr); } finally { _Connect.Close(); } if (_ErrorNumber == 0) { _ErrorNumber = (int)_oCommand.Parameters["@nError"].Value; if (_ErrorNumber != 0) { _ErrorStr = "Ошибка при сохранении путевого листа...\r\n" + _oCommand.Parameters["@cErrorText"].Value; RFMMessage.MessageBoxError(_ErrorStr); } // при создании нового пут.листа - получим его код if ((!_ID.HasValue || _ID == 0) && !Convert.IsDBNull(_oCommand.Parameters["@nWayBillID"].Value)) { _ID = (int)_oCommand.Parameters["@nWayBillID"].Value; } } return(_ErrorNumber == 0); }
/// <summary> /// сохранение данных пользователя /// </summary> public bool SaveOne() { if (_ID == null) { _ErrorNumber = -20; _ErrorStr = "Не заданы параметры пользователя..."; RFMMessage.MessageBoxError(_ErrorStr); return(false); } try { _Connect.Open(); } catch (Exception ex) { _ErrorNumber = -1; _ErrorStr = "Ошибка при соединении с сервером...\n" + ex.Message; RFMMessage.MessageBoxError(_ErrorStr); return(false); } RFMUtilities.DataTableToTempTable(TableRolesForUser, "#RolesForUser", _Connect); string _sqlCommand = "execute up_UsersSave @nUserID output, " + "@cUserName, " + "@cPassword, " + "@cAlias, " + "@cLocPath, @cNetPath, " + "@bIsAdmin, " + "@nEmployeeID, " + "@bActual, " + "@nHostID, " + "@nError output, @cErrorText output"; SqlCommand _oCommand = new SqlCommand(_sqlCommand, _Connect); #region up_UsersSave parameters SqlParameter _oParameter = _oCommand.Parameters.Add("@nUserID", SqlDbType.Int); _oParameter.Direction = ParameterDirection.InputOutput; _oParameter.Value = _ID; _oParameter = _oCommand.Parameters.Add("@cUserName", SqlDbType.VarChar); _oParameter.Value = _Name; _oParameter = _oCommand.Parameters.Add("@cPassword", SqlDbType.VarChar); _oParameter.Value = _Password; _oParameter = _oCommand.Parameters.Add("@cAlias", SqlDbType.VarChar); if (_Alias != null) { _oParameter.Value = _Alias; } else { _oParameter.Value = DBNull.Value; } _oParameter = _oCommand.Parameters.Add("@cLocPath", SqlDbType.VarChar); _oParameter.Value = _LocPath; _oParameter = _oCommand.Parameters.Add("@cNetPath", SqlDbType.VarChar); _oParameter.Value = _NetPath; _oParameter = _oCommand.Parameters.Add("@bIsAdmin", SqlDbType.Bit); _oParameter.Value = _IsAdmin; _oParameter = _oCommand.Parameters.Add("@nEmployeeID", SqlDbType.Int); if (_EmployeeID.HasValue) { _oParameter.Value = _EmployeeID; } else { _oParameter.Value = DBNull.Value; } _oParameter = _oCommand.Parameters.Add("@bActual", SqlDbType.Bit); _oParameter.Value = _Actual; _oParameter = _oCommand.Parameters.Add("@nHostID", SqlDbType.Int); if (_HostID.HasValue) { _oParameter.Value = _HostID; } else { _oParameter.Value = DBNull.Value; } _oParameter = _oCommand.Parameters.Add("@nError", SqlDbType.Int); _oParameter.Direction = ParameterDirection.InputOutput; _oParameter.Value = 0; _oParameter = _oCommand.Parameters.Add("@cErrorText", SqlDbType.VarChar, 200); _oParameter.Direction = ParameterDirection.InputOutput; _oParameter.Value = ""; #endregion try { _oCommand.ExecuteScalar(); } catch (Exception ex) { _ErrorNumber = -10; _ErrorStr = "Ошибка при сохранении данных пользователя...\r\n" + ex.Message; RFMMessage.MessageBoxError(_ErrorStr); } finally { _Connect.Close(); } if (_ErrorNumber == 0) { _ErrorNumber = (int)_oCommand.Parameters["@nError"].Value; if (_ErrorNumber != 0) { _ErrorStr = "Ошибка при сохранении данных пользователя...\r\n" + _oCommand.Parameters["@cErrorText"].Value; RFMMessage.MessageBoxError(_ErrorStr); } // при создании нового пользователя - получим его код if (_ID == 0 && !Convert.IsDBNull(_oCommand.Parameters["@nUserID"].Value)) { _ID = (int)_oCommand.Parameters["@nUserID"].Value; } } return(_ErrorNumber == 0); }
public bool SaveSalaryTariffs(ref int?nSalaryTariffID) { String _sqlCommand = "execute up_SalaryTariffsSave @nID output, " + "@nError output, @cErrorText output"; SqlCommand _oCommand = new SqlCommand(_sqlCommand, _Connect); #region up_SalaryTariffsSave parameters SqlParameter _oParameter = _oCommand.Parameters.Add("@nID", SqlDbType.Int); if (nSalaryTariffID.HasValue) { _oParameter.Value = nSalaryTariffID; } else { _oParameter.Value = DBNull.Value; } _oParameter.Direction = ParameterDirection.InputOutput; _oParameter = _oCommand.Parameters.Add("@nError", SqlDbType.Int); _oParameter.Direction = ParameterDirection.InputOutput; _oParameter.Value = 0; _oParameter = _oCommand.Parameters.Add("@cErrorText", SqlDbType.VarChar, 200); _oParameter.Direction = ParameterDirection.InputOutput; _oParameter.Value = ""; #endregion try { _Connect.Open(); RFMUtilities.DataTableToTempTable(TableSalaryTariffs, "#SalaryTariffs", _Connect); _oCommand.ExecuteScalar(); } catch (Exception ex) { _ErrorNumber = -12; _ErrorStr = "Ошибка при сохранении тарифов...\r\n" + ex.Message; RFMMessage.MessageBoxError(_ErrorStr); } finally { _Connect.Close(); } if (_ErrorNumber == 0) { _ErrorNumber = (int)_oCommand.Parameters["@nError"].Value; if (_ErrorNumber != 0) { _ErrorStr = "Ошибка при сохранении тарифов...\r\n" + _oCommand.Parameters["@cErrorText"].Value; RFMMessage.MessageBoxError(_ErrorStr); } // при создании новой записи - получим ее код if (!Convert.IsDBNull(_oCommand.Parameters["@nID"].Value) && (!nSalaryTariffID.HasValue || nSalaryTariffID == 0)) { nSalaryTariffID = (int)_oCommand.Parameters["@nID"].Value; } } return(_ErrorNumber == 0); }
/// <summary> /// подтверждение перемещения /// </summary> public bool ConfirmData(int nMovingID, int nUserID) { string _sqlCommand = "execute up_MovingsConfirm @nMovingID, @nUserID, " + "@nError output, @cErrorStr output"; SqlCommand _oCommand = new SqlCommand(_sqlCommand, _Connect); _oCommand.CommandTimeout = 0; #region up_MovingsConfirm parameters SqlParameter _oParameter = _oCommand.Parameters.Add("@nMovingID", SqlDbType.Int); _oParameter.Value = nMovingID; _oParameter = _oCommand.Parameters.Add("@nUserID", SqlDbType.Int); _oParameter.Value = nUserID; _oParameter = _oCommand.Parameters.Add("@nError", SqlDbType.Int); _oParameter.Direction = ParameterDirection.InputOutput; _oParameter.Value = 0; _oParameter = _oCommand.Parameters.Add("@cErrorStr", SqlDbType.VarChar, 200); _oParameter.Direction = ParameterDirection.InputOutput; _oParameter.Value = ""; #endregion try { _Connect.Open(); RFMUtilities.DataTableToTempTable(TableMovingsGoods, "#MovingsGoods", _Connect); _oCommand.ExecuteScalar(); } catch (Exception ex) { // здесь возвращаются все ошибки, возникшие в ходе подтверждения. это нормально! /* * _ErrorNumber = -11; * _ErrorStr = "Ошибка при подтверждении перемещения...\r\n" + ex.Message; * RFMMessage.MessageBoxError(_ErrorStr); */ RFMMessage.MessageBoxError(ex.Message); } finally { _Connect.Close(); } if (_ErrorNumber == 0) { _ErrorNumber = (int)_oCommand.Parameters["@nError"].Value; if (_ErrorNumber != 0) { _ErrorStr = "Ошибка при подтверждении перемещения...\r\n" + _oCommand.Parameters["@cErrorStr"].Value; if (_ErrorNumber > 0) { RFMMessage.MessageBoxError(_ErrorStr); } } } return(_ErrorNumber == 0); }
/// <summary> /// сохранение внутр.перемещения /// </summary> public bool SaveData(int nMovingID, int?nCellTargetID, int nUserID) { if (_MainTable.Rows.Count == 0 || _MainTable.Rows[0] == null) { _ErrorNumber = -20; _ErrorStr = "Нет данных для сохранения внутр.перемещения..."; RFMMessage.MessageBoxError(_ErrorStr); return(false); } DataRow r = _MainTable.Rows[0]; String _sqlCommand = "execute up_MovingsSave @nMovingID output, " + "@dDateMoving, " + "@nMovingTypeID, " + "@nOwnerID, @nGoodStateID, @nGoodStateNewID, " + "@nCellSourceID, " + "@nCellTargetID, " + "@cNote, " + "@nUserID, " + "@nError output, @cErrorText output"; SqlCommand _oCommand = new SqlCommand(_sqlCommand, _Connect); #region up_MovingsSave parameters SqlParameter _oParameter = _oCommand.Parameters.Add("@nMovingID", SqlDbType.Int); _oParameter.Value = nMovingID; _oParameter.Direction = ParameterDirection.InputOutput; _oParameter = _oCommand.Parameters.Add("@dDateMoving", SqlDbType.DateTime); _oParameter.Value = DateTime.Parse(r["DateMoving"].ToString()); _oParameter = _oCommand.Parameters.Add("@nMovingTypeID", SqlDbType.Int); _oParameter.Value = Convert.ToInt32(r["MovingTypeID"]); _oParameter = _oCommand.Parameters.Add("@nOwnerID", SqlDbType.Int); if (!Convert.IsDBNull(r["OwnerID"])) { _oParameter.Value = Convert.ToInt32(r["OwnerID"]); } else { _oParameter.Value = DBNull.Value; } _oParameter = _oCommand.Parameters.Add("@nGoodStateID", SqlDbType.Int); _oParameter.Value = Convert.ToInt32(r["GoodStateID"]); _oParameter = _oCommand.Parameters.Add("@nGoodStateNewID", SqlDbType.Int); _oParameter.Value = Convert.ToInt32(r["GoodStateNewID"]); _oParameter = _oCommand.Parameters.Add("@nCellSourceID", SqlDbType.Int); _oParameter.Value = Convert.ToInt32(r["CellSourceID"]); _oParameter = _oCommand.Parameters.Add("@nCellTargetID", SqlDbType.Int); if (nCellTargetID.HasValue) { _oParameter.Value = nCellTargetID; } else { _oParameter.Value = DBNull.Value; } _oParameter = _oCommand.Parameters.Add("@cNote", SqlDbType.VarChar); _oParameter.Value = r["Note"].ToString(); _oParameter = _oCommand.Parameters.Add("@nUserID", SqlDbType.Int); _oParameter.Value = nUserID; _oParameter = _oCommand.Parameters.Add("@nError", SqlDbType.Int); _oParameter.Direction = ParameterDirection.InputOutput; _oParameter.Value = 0; _oParameter = _oCommand.Parameters.Add("@cErrorText", SqlDbType.VarChar, 200); _oParameter.Direction = ParameterDirection.InputOutput; _oParameter.Value = ""; #endregion try { _Connect.Open(); // с использованием временной таблицы перемещений MovingsGoods RFMUtilities.DataTableToTempTable(TableMovingsGoods, "#MovingsGoods", _Connect); _oCommand.ExecuteScalar(); } catch (Exception ex) { _ErrorNumber = -10; _ErrorStr = "Ошибка при сохранении внутр.перемещения...\r\n" + ex.Message; RFMMessage.MessageBoxError(_ErrorStr); } finally { _Connect.Close(); } if (_ErrorNumber == 0) { _ErrorNumber = (int)_oCommand.Parameters["@nError"].Value; if (_ErrorNumber != 0) { _ErrorStr = "Ошибка при сохранении внутр.перемещения...\r\n" + _oCommand.Parameters["@cErrorText"].Value; RFMMessage.MessageBoxError(_ErrorStr); } // при создании нового внутр.перемещения - получим его код if (nMovingID == 0 && _oCommand.Parameters["@nMovingID"].Value != DBNull.Value) { _ID = (int)_oCommand.Parameters["@nMovingID"].Value; } } return(_ErrorNumber == 0); }
private void mniServiceTrafficGoodChangeUser_Click(object sender, EventArgs e) { RFMMenuUtilities.MenuClear((ToolStripMenuItem)sender); if (grdData.DataSource == null || grdData.Rows.Count == 0) { return; } // текущая запись или все отмеченные string sText = "Зарегистрировать сотрудника, выполнявшего "; int nCnt = CalcMarkedRows(); if (nCnt == 0) { if (grdData.CurrentRow == null || grdData.IsStatusRow(grdData.CurrentRow.Index)) { return; } sText += "текущее перемещение"; nCnt = 1; } else { sText += RFMUtilities.Declen(nCnt, "отмеченное перемещение", "отмеченных перемещения", "отмеченных перемещений"); } sText += " коробок/штук?"; if (RFMMessage.MessageBoxYesNo(sText) == DialogResult.Yes) { // список сотрудников User oUser = new User(); oUser.FilterActual = true; oUser.FillData(); if (oUser.ErrorNumber != 0 || oUser.MainTable == null) { RFMMessage.MessageBoxError("Ошибка при получении данных о сотрудниках..."); return; } if (oUser.MainTable.Rows.Count == 0) { RFMMessage.MessageBoxError("Нет данных о сотрудниках..."); return; } int nNewUserID = 0; string sNewUserName = ""; _SelectedID = null; if (StartForm(new frmSelectID(this, oUser.MainTable, "Name", "Сотрудник", "Сотрудник, выполнявший перемещения")) == DialogResult.Yes) { if (_SelectedID.HasValue) { nNewUserID = (int)_SelectedID; sNewUserName = _SelectedText; } } if (nNewUserID == 0) { return; } TrafficGood oTrafficGoodForChangeUser = new TrafficGood(); TrafficPrepareIDList(oTrafficGoodForChangeUser, true); if (!oTrafficGoodForChangeUser.ID.HasValue && (oTrafficGoodForChangeUser.IDList == null || oTrafficGoodForChangeUser.IDList.Length == 0)) { oTrafficGoodForChangeUser.ID = Convert.ToInt32(grdData.CurrentRow.Cells["grcID"].Value); } oTrafficGoodForChangeUser.FillData(); if (oTrafficGoodForChangeUser.ErrorNumber != 0 || oTrafficGoodForChangeUser.MainTable == null) { RFMMessage.MessageBoxError("Ошибка при получении данных о перемещениях коробок/штук..."); return; } if (oTrafficGoodForChangeUser.MainTable.Rows.Count == 0) { RFMMessage.MessageBoxError("Нет данных о выбранных перемещениях коробок/штук..."); return; } // уже есть данные о сотрудниках в выбранных перемещениях? int nOldUsersCnt = 0; foreach (DataRow tr in oTrafficGoodForChangeUser.MainTable.Rows) { if (!Convert.IsDBNull(tr["UserID"])) { nOldUsersCnt++; } } if (nOldUsersCnt > 0) { if (oTrafficGoodForChangeUser.MainTable.Rows.Count == 1) { // одно перемещение if (RFMMessage.MessageBoxYesNo("Для выбранного перемещения уже зарегистрирован сотрудник.\n" + "Все-таки зарегистрировать нового сотрудника \"" + sNewUserName + "\"?") != DialogResult.Yes) { return; } } else { // не одно перемещение if (RFMMessage.MessageBoxYesNo("Для " + nOldUsersCnt.ToString().Trim() + " из " + RFMUtilities.Declen(nCnt, " выбранного перемещения", "выбранных перемещений", "выбранных перемещений") + " коробок/штук уже зарегистрирован сотрудник.\n" + "Все-таки зарегистрировать нового сотрудника \"" + sNewUserName + "\" для всех " + RFMUtilities.Declen(nCnt, " выбранного перемещения", "выбранных перемещений", "выбранных перемещений") + " коробок/штук?") != DialogResult.Yes) { return; } } } foreach (DataRow tr in oTrafficGoodForChangeUser.MainTable.Rows) { oTrafficGoodForChangeUser.UserChange((int)tr["ID"], nNewUserID); } grdData_Restore(); } }