private bool cboOutputDocumentType_Restore() { cboOutputDocumentType.DataSource = null; oOutputDocument.ClearError(); if (oOutputDocument.FillTableOutputsDocumentsTypes()) { cboOutputDocumentType.ValueMember = "ID"; cboOutputDocumentType.DisplayMember = "Name"; cboOutputDocumentType.Restore(oOutputDocument.TableOutputsDocumentsTypes); } return(oOutputDocument.ErrorNumber == 0); }
private bool grdOutputsDocuments_Restore() { RFMCursorWait.Set(true); RFMCursorWait.LockWindowUpdate(FindForm().Handle); oOutputDocumentCur.ClearOne(); oOutputDocumentList.ClearError(); oOutputDocumentList.ClearFilters(); oOutputDocumentList.ID = null; oOutputDocumentList.IDList = null; grdOutputsDocuments.GetGridState(); grdOutputsDocumentsGoods.DataSource = null; oTrip.FillTableOutputsDocumentsInTrip(chkOutputsShowCarried.Checked); grdOutputsDocuments.IsLockRowChanged = true; grdOutputsDocuments.Restore(oTrip.TableOutputsDocumentsInTrip); tmrRestore.Enabled = true; RecalcSumOutputsDocuments(); ShowTotalInfo("OUTPUTSDOCUMENTS"); RFMCursorWait.LockWindowUpdate(IntPtr.Zero); RFMCursorWait.Set(false); return(oTrip.ErrorNumber == 0); }
private bool dgvOuputsGoods_Restore() { oOutputDocument.ClearError(); oOutputDocument.FillTableOutputsDocumentsGoods(); oOutputDocument.TableOutputsDocumentsGoods.PrimaryKey = null; oOutputDocument.TableOutputsDocumentsGoods.Columns["ID"].Unique = false; oOutputDocument.TableOutputsDocumentsGoods.Columns["ID"].AllowDBNull = true; //oOutputDocument.TableOutputsDocumentsGoods.PrimaryKey = new DataColumn[] { oOutputDocument.TableOutputsDocumentsGoods.Columns["OutputDocumentGoodID"] }; oOutputDocument.TableOutputsDocumentsGoods.Columns.Add("NNumber", System.Type.GetType("System.Int16")); int i = 0; decimal nAmount = 0; decimal nQnt = 0; decimal nBox = 0; foreach (DataRow droRow in oOutputDocument.TableOutputsDocumentsGoods.Rows) { droRow["BoxBrought"] = droRow["BoxConfirmed"]; droRow["QntBrought"] = droRow["QntConfirmed"]; nQnt += (decimal)droRow["QntBrought"]; nBox += (decimal)droRow["BoxBrought"]; nAmount += (decimal)droRow["QntBrought"] * (decimal)droRow["Price"]; if (Convert.IsDBNull(droRow["Vat"]) || droRow["Vat"] == null) { droRow["Vat"] = 0; } i++; droRow["NNumber"] = i; } dgvOutputsDocumentsGoods.Restore(oOutputDocument.TableOutputsDocumentsGoods); lblTotalAmount.Text = nAmount.ToString("### ### ##0.00").Trim(); lblTotalQnt.Text = nQnt.ToString("### ### ##0").Trim(); lblTotalBox.Text = nBox.ToString("# ### ##0.0").Trim(); lblTotalStrikesCnt.Text = ""; return(oOutputDocument.ErrorNumber == 0); }
private bool grdOutputsDocuments_Restore() { RFMCursorWait.Set(true); RFMCursorWait.LockWindowUpdate(FindForm().Handle); oOutputDocumentCur.ClearOne(); oOutputDocumentList.ClearError(); oOutputDocumentList.ClearFilters(); oOutputDocumentList.ID = null; oOutputDocumentList.IDList = null; // собираем условия // даты if (!dtrDates.dtpBegDate.IsEmpty) { oOutputDocumentList.FilterDateBeg = dtrDates.dtpBegDate.Value.Date; } if (!dtrDates.dtpEndDate.IsEmpty) { oOutputDocumentList.FilterDateEnd = dtrDates.dtpEndDate.Value.Date; } // доставка? if (optDeliveryNeed.Checked) { oOutputDocumentList.FilterDeliveryNeed = true; } if (optDeliveryNeedNot.Checked) { oOutputDocumentList.FilterDeliveryNeed = false; } // клиенты-поставщики if (txtPartnerSourceNameContext.Text.Trim().Length > 0) { Partner oPartnerSource = new Partner(); oPartnerSource.FilterNameContext = txtPartnerSourceNameContext.Text.Trim(); oPartnerSource.FillData(); oOutputDocumentList.FilterPartnersSourceList = ""; foreach (DataRow rcs in oPartnerSource.MainTable.Rows) { oOutputDocumentList.FilterPartnersSourceList += rcs["ID"].ToString() + ","; } } if (ucSelectRecordID_PartnersSource.IsSelectedExist) { oOutputDocumentList.FilterPartnersSourceList += ucSelectRecordID_PartnersSource.GetIdString(); } // клиенты-получатели if (txtPartnerTargetNameContext.Text.Trim().Length > 0) { Partner oPartnerTarget = new Partner(); oPartnerTarget.FilterNameContext = txtPartnerTargetNameContext.Text.Trim(); oPartnerTarget.FillData(); oOutputDocumentList.FilterPartnersTargetList = ""; foreach (DataRow rct in oPartnerTarget.MainTable.Rows) { oOutputDocumentList.FilterPartnersTargetList += rct["ID"].ToString() + ","; } } if (ucSelectRecordID_PartnersTarget.IsSelectedExist) { oOutputDocumentList.FilterPartnersTargetList += ucSelectRecordID_PartnersTarget.GetIdString(); } // владельцы if (ucSelectRecordID_Owners.IsSelectedExist) { oOutputDocumentList.FilterOwnersList = ucSelectRecordID_Owners.GetIdString(); } // рейс? if (optTripExists.Checked) { oOutputDocumentList.FilterTripExists = true; } if (optTripExistsNot.Checked) { oOutputDocumentList.FilterTripExists = false; } // задания на расход? if (optOutputExists.Checked) { oOutputDocumentList.FilterIsOutputExists = true; } if (optOutputExistsNot.Checked) { oOutputDocumentList.FilterIsOutputExists = false; } // выбранные товары if (sSelectedPackingsIDList.Length > 0) { oOutputDocumentList.FilterPackingsList = sSelectedPackingsIDList; } // подтверждение отгрузки if (optOutputsDocumentsIsConfirmedNot.Checked) { oOutputDocumentList.FilterIsConfirmed = false; } if (optOutputsDocumentsIsConfirmed.Checked) { oOutputDocumentList.FilterIsConfirmed = true; } // подтверждение доставки if (optOutputsDocumentsIsBroughtNot.Checked) { oOutputDocumentList.FilterIsBrought = false; } if (optOutputsDocumentsIsBrought.Checked) { oOutputDocumentList.FilterIsBrought = true; } // по рейсу string sTripsList = ""; if (txtTripAliasContext.Text.Trim().Length > 0) { Trip oTripFilter = new Trip(); oTripFilter.FilterAliasContext = txtTripAliasContext.Text.Trim(); oTripFilter.FillData(); if (oTripFilter.ErrorNumber == 0 && oTripFilter.MainTable != null) { foreach (DataRow tr in oTripFilter.MainTable.Rows) { sTripsList += tr["ID"].ToString() + ","; } } oOutputDocumentList.FilterTripsList = sTripsList; } if (numTripID.Value > 0) { if (oOutputDocumentList.FilterTripsList == null) { oOutputDocumentList.FilterTripsList = Convert.ToInt32(numTripID.Value).ToString(); } else { oOutputDocumentList.FilterTripsList += Convert.ToInt32(numTripID.Value).ToString(); } } // хосты if (nUserHostID.HasValue) { oOutputDocumentList.FilterHostsList = nUserHostID.ToString(); } else { if (ucSelectRecordID_Hosts.IsSelectedExist) { oOutputDocumentList.FilterHostsList = ucSelectRecordID_Hosts.GetIdString(); } } // // начальные условия if (oOutputDocument != null) { if (oOutputDocument.FilterOwnersList != null) { oOutputDocumentList.FilterOwnersList = oOutputDocument.FilterOwnersList; } if (oOutputDocument.FilterPartnersSourceList != null) { oOutputDocumentList.FilterPartnersSourceList = oOutputDocument.FilterPartnersSourceList; } if (oOutputDocument.FilterPartnersTargetList != null) { oOutputDocumentList.FilterPartnersTargetList = oOutputDocument.FilterPartnersTargetList; } if (oOutputDocument.FilterHostsList != null) { if (!nUserHostID.HasValue) { oOutputDocumentList.FilterHostsList = oOutputDocument.FilterHostsList; } else { if (!((string)("," + oOutputDocument.FilterHostsList + ",")).Contains("," + nUserHostID.ToString().Trim() + ",")) { oOutputDocumentList.FilterHostsList = "-1"; } } } } grdOutputsDocumentsGoods.DataSource = null; grdOutputsDocuments.GetGridState(); oOutputDocumentList.FillData(); grdOutputsDocuments.IsLockRowChanged = true; grdOutputsDocuments.Restore(oOutputDocumentList.MainTable); tmrRestore.Enabled = true; RFMCursorWait.LockWindowUpdate(IntPtr.Zero); RFMCursorWait.Set(false); return(oOutputDocumentList.ErrorNumber == 0); }
private void btnSave_Click(object sender, EventArgs e) { oOutputDocument.ClearError(); if (!bCarry) { // дл¤ заказа в целом if (pnlOutputDocument.Enabled) { // причина if (cboOutputDocumentFailReason.SelectedValue == null || cboOutputDocumentFailReason.SelectedIndex < 0) { RFMMessage.MessageBoxError("Ќе указана причина проблемы дл¤ документа в целом..."); cboOutputDocumentFailReason.Select(); return; } oOutputDocument.ChangeOutputDocumentFailReason(nID, (int)cboOutputDocumentFailReason.SelectedValue); // виновник-текст if (txtGuiltyEmployees.Text.Trim().Length > 0) { oOutputDocument.SetGuiltyEmployees(nID, null, txtGuiltyEmployees.Text.Trim(), chkIsDriverFoul.Checked); } else { // сохран¤ем пустое значение виновника-текста if (oOutputDocument.GuiltyEmployees != null && oOutputDocument.GuiltyEmployees.Length > 0) { // очистка виновника-текста if (RFMMessage.MessageBoxYesNo("ќчистить данные о виновниках проблемы дл¤ документа в целом?") == DialogResult.Yes) { oOutputDocument.SetGuiltyEmployees(nID, null, "", false); } } } } // дл¤ товаров if (pnlOutputDocumentGoods.Enabled) { // провер¤ем указание причины foreach (DataRow rGood in dt.Rows) { if ((decimal)rGood["QntConfirmed"] != (decimal)rGood["QntWished"]) { if (rGood["ReturnReasonID"] == null || rGood["ReturnReasonID"] == DBNull.Value) { RFMMessage.MessageBoxError("Ќе указана причина несоответстви¤ отгруженного и доставленного количества дл¤ товара\n" + rGood["GoodName"].ToString() + "..."); int nGridPosition = ((RFMBindingSource)grdOutputsDocumentsGoods.GridSource).Find("ID", (int)rGood["ID"]); if (nGridPosition >= 0) { grdOutputsDocumentsGoods.GridSource.Position = nGridPosition; } return; } } } foreach (DataRow rGood in dt.Rows) { int nOutputDocumentGoodID = (int)rGood["ID"]; // причина if (rGood["ReturnReasonID"] != null && rGood["ReturnReasonID"] != DBNull.Value) { oOutputDocument.ChangeOutputDocumentGoodReturnReason(nOutputDocumentGoodID, (int)rGood["ReturnReasonID"]); if (oOutputDocument.ErrorNumber != 0) { return; } } // виновник-текст oOutputDocument.SetGuiltyEmployees(null, nOutputDocumentGoodID, rGood["GuiltyEmployees"].ToString(), false); if (oOutputDocument.ErrorNumber != 0) { return; } } } } else { // дл¤ переноса if (cboOutputDocumentFailReason.SelectedValue == null || cboOutputDocumentFailReason.SelectedIndex < 0) { RFMMessage.MessageBoxError("Ќе указана причина проблемы (переноса) заказа..."); cboOutputDocumentFailReason.Select(); return; } oOutputDocument.ChangeOutputDocumentCarryFailReasonGuiltyEmployees(nCarryID, (int)cboOutputDocumentFailReason.SelectedValue, txtGuiltyEmployees.Text.Trim(), chkIsDriverFoul.Checked); } if (oOutputDocument.ErrorNumber == 0) { DialogResult = DialogResult.Yes; Dispose(); } }
private bool dgvOutputsDocuments_Restore() { oOutputDocument.ClearError(); oOutputDocument.FilterTripsList = nTripID.ToString(); oOutputDocument.FillData(); if (oOutputDocument.ErrorNumber == 0) { dt = oOutputDocument.MainTable; dt.Columns.Add("TimeBeg", Type.GetType("System.String")); dt.Columns.Add("TimeEnd", Type.GetType("System.String")); DataColumn dc = dt.Columns.Add("IsUnique", Type.GetType("System.Boolean")); dc.DefaultValue = false; DataRow dr; string sDate; for (int nI = 0; nI < dt.Rows.Count; nI++) { dr = dt.Rows[nI]; if (dr["DateBegFact"] == DBNull.Value) { sDate = "ddMMyyyy00:00"; } else { sDate = (Convert.ToDateTime(dr["DateBegFact"])).ToString("ddMMyyyyHH:mm"); } if (sDate.Length > 0) { dr["TimeBeg"] = sDate.Substring(8, 5); } if (dr["DateEndFact"] == DBNull.Value) { sDate = "ddMMyyyy00:00"; } else { sDate = (Convert.ToDateTime(dr["DateEndFact"])).ToString("ddMMyyyyHH:mm"); } if (sDate.Length > 0) { dr["TimeEnd"] = sDate.Substring(8, 5); } } int idMask = -1, idValue; DataRowView drv; dt.DefaultView.Sort = "PartnerTargetID"; for (int i = 0; i < dt.DefaultView.Count; i++) { drv = dt.DefaultView[i]; idValue = (int)drv["PartnerTargetID"]; if (idMask != idValue) { drv["IsUnique"] = true; idMask = idValue; } } dgvOutputsDocuments.Restore(dt); dgvOutputsDocuments.GridSource.Filter = "IsUnique"; dgvOutputsDocuments.GridSource.Sort = "ByOrder" + (oTrip.IsPostern ? " desc" : "") + ", PartnerTargetName"; } return(oOutputDocument.ErrorNumber == 0); }