private void btnAdd_Click(object sender, EventArgs e)
        {
            _SelectedPackingID = null;
            if (StartForm(new frmSelectOnePacking(this, false, null, nHostID)) == DialogResult.Yes)
            {
                if (_SelectedPackingID != null)
                {
                    // проверить, нет ли уже такой строки
                    foreach (DataRow r in dt.Rows)
                    {
                        if (Convert.ToInt32(r["PackingID"]) == _SelectedPackingID)
                        {
                            dgvGoods.GridSource.Position = dgvGoods.GridSource.Find("PackingID", _SelectedPackingID);
                            if (dgvGoods.GridSource.Position < 0)
                            {
                                dgvGoods.GridSource.MoveFirst();
                            }
                            return;
                        }
                    }

                    oGood.PackingID = _SelectedPackingID;
                    oGood.FillData();
                    // выбранный товар
                    DataRow rg = oGood.MainTable.Rows[0];
                    // добавляем новую строку для выбранного товара
                    DataRow dr = dt.Rows.Add(-1, -1);
                    dr["PackingID"]          = _SelectedPackingID;
                    dr["GoodID"]             = rg["GoodID"];
                    dr["ReturnQnt"]          =
                        dr["ReturnBox"]      =
                            dr["ActQnt"]     =
                                dr["ActBox"] =
                                    0;
                    dr["GoodName"]      = rg["GoodName"];
                    dr["GoodAlias"]     = rg["GoodAlias"];
                    dr["PackingAlias"]  = rg["PackingAlias"];
                    dr["GoodBarCode"]   = rg["GoodBarCode"];
                    dr["Articul"]       = rg["Articul"];
                    dr["GoodGroupName"] = rg["GoodGroupName"];
                    dr["GoodBrandName"] = rg["GoodBrandName"];
                    dr["CountryName"]   = rg["CountryName"];
                    dr["InBox"]         = rg["InBox"];
                    dr["Weighting"]     = rg["Weighting"];

                    dr["OutputID"] = 0;

                    // и встаем на эту строку
                    dgvGoods.GridSource.Position = dgvGoods.GridSource.Find("PackingID", _SelectedPackingID);
                    if (dgvGoods.GridSource.Position < 0)
                    {
                        dgvGoods.GridSource.MoveFirst();
                    }
                    // встать на найденную строку, в ячейку "Коробок заказ"
                    dgvGoods.CurrentCell = dgvGoods.Rows[dgvGoods.GridSource.Position].Cells["dgvcReturnBox"];
                    dgvGoods.Select();
                }
                _SelectedPackingID = null;
            }
        }
Ejemplo n.º 2
0
 private bool cboGood_Restore()
 {
     oGood.FillData();
     cboGood.ValueMember   = oGood.MainTable.Columns["PackingID"].Caption;
     cboGood.DisplayMember = oGood.MainTable.Columns["PackingAlias"].Caption;
     cboGood.DataSource    = oGood.MainTable;
     return(oGood.ErrorNumber == 0);
 }
Ejemplo n.º 3
0
        private void btnPackings_Click(object sender, EventArgs e)
        {
            _SelectedPackingID    = null;
            nPackingAddID         = null;
            pnlDataChange.Enabled = false;
            if (StartForm(new frmSelectOnePacking(this, false)) == DialogResult.Yes)
            {
                if (_SelectedPackingID != null)
                {
                    nPackingAddID         = _SelectedPackingID;
                    cboGood.SelectedValue = Convert.ToInt32(_SelectedPackingID);
                    txtGood.Text          = cboGood.Text;
                }
                _SelectedPackingID = null;

                oGoodAdd.PackingID = nPackingAddID;
                oGoodAdd.FillData();

                DataRow r = oGoodAdd.MainTable.Rows[0];
                if (r != null)
                {
                    txtGood.Text = r["PackingAlias"].ToString();
                    // срок годности
                    if (r["Retention"] != DBNull.Value && r["Retention"] != null)
                    {
                        dtpDateValid.Value = DateTime.Now.Date.AddDays(Convert.ToInt32(r["Retention"]));
                    }
                    // весовой
                    decimal nInBox        = 1;
                    bool    bDecimalInBox = false;
                    bool    bWeighting    = false;
                    if (r["InBox"] != DBNull.Value && r["InBox"] != null)
                    {
                        nInBox        = (decimal)r["InBox"];
                        bDecimalInBox = ((int)nInBox != nInBox);
                    }
                    if (r["Weighting"] != DBNull.Value && r["Weighting"] != null)
                    {
                        bWeighting = (bool)r["Weighting"];
                    }
                    numRestQnt.DecimalPlaces = ((bWeighting || bDecimalInBox) ? 3 : 0);
                    numRestQnt.InputMask     = ((bWeighting || bDecimalInBox) ? "########0.000" : "########0");
                    numRestQnt.Refresh();

                    numBoxQnt.Enabled = (!bWeighting);
                }
            }
            pnlDataChange.Enabled = true;

            if (numBoxQnt.Enabled)
            {
                numBoxQnt.Select();
            }
            else
            {
                numRestQnt.Select();
            }
        }
Ejemplo n.º 4
0
 private bool cboFixedPacking_Restore(int nFixedPacking)
 {
     oFixedPacking.ID = nFixedPacking;
     oFixedPacking.FillData();
     cboFixedPacking.DataSource    = oFixedPacking.MainTable;
     cboFixedPacking.ValueMember   = oFixedPacking.ColumnID;
     cboFixedPacking.DisplayMember = oFixedPacking.ColumnName;
     return(oFixedPacking.ErrorNumber == 0);
 }
Ejemplo n.º 5
0
 private bool _PackingSelect(int _nPackingID)
 {
     oPacking.PackingID = (int)_nPackingID;
     oPacking.FillData();
     if (oPacking.ErrorNumber != 0 || oPacking.MainTable == null || oPacking.MainTable.Rows.Count != 1)
     {
         RFMMessage.MessageBoxError("ќшибка при получении данных о товаре...");
         return(false);
     }
     txtPackingAlias.Text = oPacking.MainTable.Rows[0]["Alias"].ToString();
     return(true);
 }
        private void btnPackings_Click(object sender, EventArgs e)
        {
            _SelectedPackingID = null;
            nPackingID         = null;
            if (StartForm(new frmSelectOnePacking(this, false)) == DialogResult.Yes)
            {
                if (_SelectedPackingID != null)
                {
                    // проверка наличия пикинговой ячейки для товара
                    oCellPicking.ClearError();
                    oCellPicking.ClearFilters();
                    oCellPicking.FilterFixedPackingsList       = _SelectedPackingID.ToString();
                    oCellPicking.FilterStoreZoneTypeForStorage = true;
                    oCellPicking.FilterStoreZoneTypeForPicking = true;
                    oCellPicking.FillData();
                    string sErrorText = "";
                    if (oCellPicking.ErrorNumber != 0 || oCellPicking.MainTable == null)
                    {
                        sErrorText = "Ошибка при поиске ячейки пикинга...";
                    }
                    if (sErrorText.Length == 0 && oCellPicking.MainTable.Rows.Count == 0)
                    {
                        sErrorText = "Не найдена ячейка пикинга для товара...";
                    }
                    if (sErrorText.Length == 0 && oCellPicking.MainTable.Rows.Count > 1)
                    {
                        sErrorText = "Найдено несколько ячеек пикинга для товара...";
                    }
                    if (sErrorText.Length == 0)
                    {
                        nCellFinishID      = Convert.ToInt32(oCellPicking.MainTable.Rows[0]["ID"]);
                        sCellFinishAddress = oCellPicking.MainTable.Rows[0]["Address"].ToString();
                        nPackingID         = _SelectedPackingID;
                        txtGood.Text       = _SelectedPackingAliasText + ": ячейка пикинга " + oCellPicking.MainTable.Rows[0]["Address"];

                        oGood.PackingID = (int)nPackingID;
                        oGood.FillData();
                        if (oGood.ErrorNumber == 0 && oGood.MainTable.Rows.Count == 1)
                        {
                            bWeighting = Convert.ToBoolean(oGood.MainTable.Rows[0]["Weighting"]);
                        }
                    }
                    else
                    {
                        RFMMessage.MessageBoxError(sErrorText);
                    }
                }
                _SelectedPackingID        = null;
                _SelectedPackingAliasText = null;
            }
        }
Ejemplo n.º 7
0
        private void btnPackingsChoose_Click(object sender, EventArgs e)
        {
            _SelectedPackingIDList = null;
            if (StartForm(new frmSelectOnePacking(this, true)) == DialogResult.Yes)
            {
                int nCntChoosen = RFMPublic.RFMUtilities.Occurs(_SelectedPackingIDList, ",");

                if (_SelectedPackingIDList == null || nCntChoosen == 0)
                {
                    btnPackingsClear_Click(null, null);
                    return;
                }

                sSelectedPackingsIDList = "," + _SelectedPackingIDList;

                Good oGoodSel = new Good();
                oGoodSel.FilterPackingsIDList = _SelectedPackingIDList;
                oGoodSel.FillData();

                string sSelectedDataText = "";
                int    i = 0;
                foreach (DataRow r in oGoodSel.MainTable.Rows)
                {
                    i++;
                    if (i > 3)
                    {
                        sSelectedDataText += "...";
                        break;
                    }
                    sSelectedDataText += ", " + r["GoodAlias"].ToString().Trim();
                }
                if (sSelectedDataText.StartsWith(","))
                {
                    sSelectedDataText = sSelectedDataText.Substring(1).Trim();
                }

                txtPackingsChoosen.Text = "(" + nCntChoosen.ToString().Trim() + "): " + sSelectedDataText;
                ttToolTip.SetToolTip(txtPackingsChoosen, txtPackingsChoosen.Text);

                tabTrafficsFrames.IsNeedRestore = true;
                tabTrafficsGoods.IsNeedRestore  = true;
                tabInputsFrames.IsNeedRestore   = true;
            }

            if (sSelectedPackingsIDList != null && sSelectedPackingsIDList.Length == 0)
            {
                sSelectedPackingsIDList = null;
            }
            _SelectedPackingIDList = null;
        }
        private void btnAddGood_Click(object sender, EventArgs e)
        {
            _SelectedPackingsIDList = null;
            _SelectedPackingsIDList = _SelectedIDList = null;
            int       nGoodID = 0;
            bool      nFound  = false;
            DataTable dtSource;
            Good      oGoodTemp = new Good();

            if (_SelectedInputDocumentID != null || _SelectedInputID != null)
            {
                if (_SelectedInputDocumentID != null)
                {
                    InputDocument oInputDocument = new InputDocument();
                    oInputDocument.ID = _SelectedInputDocumentID;
                    oInputDocument.FillTableInputsDocumentsGoods();
                    if (oInputDocument.TableInputsDocumentsGoods.Rows.Count == 0)
                    {
                        RFMMessage.MessageBoxAttention("В выбранном приходном документе нет товаров...");
                        return;
                    }
                    dtSource = oInputDocument.TableInputsDocumentsGoods.Copy();
                }
                else
                {
                    Input oInput = new Input();
                    oInput.ID = _SelectedInputID;
                    oInput.FillTableInputsGoods();
                    if (oInput.TableInputsGoods.Rows.Count == 0)
                    {
                        RFMMessage.MessageBoxAttention("В выбранном задании на приход нет товаров...");
                        return;
                    }
                    dtSource = oInput.TableInputsGoods.Copy();
                }
                if (StartForm(new frmSelectID(this, dtSource,
                                              "GoodAlias, GoodBarcode, Articul, GoodGroupName, GoodBrandName, Retention, Weighting, GoodActual, CountryName, ERPCode",
                                              "Товар, Штрих-Код, Артикул, Группа, Бренд, Срок годн., Вес., Акт., Страна, ERP-код", true)) != DialogResult.Yes)
                {
                    _SelectedIDList = null;
                    return;
                }
                if (_SelectedIDList == null || !_SelectedIDList.Contains(","))
                {
                    return;
                }
                string[]      cIDList = _SelectedIDList.Split(',');
                StringBuilder sb      = new StringBuilder();
                DataRow       dr;
                for (int i = 0; i < cIDList.Length; i++)
                {
                    for (int j = 0; j < dtSource.Rows.Count; j++)
                    {
                        dr = dtSource.Rows[j];
                        if (cIDList[i] == dr["ID"].ToString())
                        {
                            sb.Append(dr["PackingID"].ToString() + ",");
                        }
                    }
                }
                oGoodTemp.PackingsIDList = "," + sb;
                oGoodTemp.FillData();
            }

            else
            {
                if (StartForm(new frmSelectOnePacking(this, true)) == DialogResult.Yes)
                {
                    if (_SelectedPackingsIDList == null || !_SelectedPackingsIDList.Contains(","))
                    {
                        return;
                    }

                    RFMCursorWait.Set(true);
                    oGoodTemp.PackingsIDList = "," + _SelectedPackingsIDList;
                    oGoodTemp.FillData();
                    if (oGoodTemp.ErrorNumber != 0 || oGoodTemp.MainTable == null || oGoodTemp.MainTable.Rows.Count == 0)
                    {
                        RFMCursorWait.Set(false);
                        return;
                    }
                }
            }
            foreach (DataRow rg in oGoodTemp.MainTable.Rows)
            {
                // нет ли уже такого товара?
                nGoodID = Convert.ToInt32(rg["GoodID"]);
                nFound  = false;

                foreach (DataRow drTemp in tGoodsVeterinaries.Rows)
                {
                    if (Convert.ToInt32(drTemp["GoodID"]) == nGoodID)
                    {
                        nFound = true;
                        if (oGoodTemp.MainTable.Rows.Count == 1)
                        {
                            RFMCursorWait.Set(false);
                            RFMMessage.MessageBoxError("Такой товар уже в списке...");
                            RFMCursorWait.Set(true);
                        }
                        break;
                    }
                }
                if (!nFound)
                {
                    // добавляем новую строку для выбранного товара
                    DataTable dtTemp = tGoodsVeterinaries.Clone();
                    dtTemp.Columns["GoodID"].AllowDBNull = true;
                    DataRow dr = dtTemp.Rows.Add();
                    dr["GoodID"]        = nGoodID;
                    dr["GoodName"]      = rg["GoodName"];
                    dr["GoodAlias"]     = rg["GoodAlias"];
                    dr["GoodBarCode"]   = rg["GoodBarCode"];
                    dr["Articul"]       = rg["Articul"];
                    dr["GoodGroupName"] = rg["GoodGroupName"];
                    dr["GoodBrandName"] = rg["GoodBrandName"];
                    dr["CountryName"]   = rg["CountryName"];
                    dr["Weighting"]     = rg["Weighting"];
                    dr["GoodActual"]    = rg["GoodActual"];
                    dr["Netto"]         = rg["Netto"];
                    dr["Brutto"]        = rg["Brutto"];
                    dr["Retention"]     = rg["Retention"];
                    dr["GoodERPCode"]   = rg["GoodERPCode"];

                    tGoodsVeterinaries.ImportRow(dr);
                }
                // встать на последнюю добавленную строку
                if (nGoodID != 0)
                {
                    grdData.GridSource.Position = grdData.GridSource.Find("GoodID", nGoodID);
                    if (grdData.GridSource.Position < 0)
                    {
                        grdData.GridSource.MoveFirst();
                    }
                }
                RFMCursorWait.Set(false);
            }
            _SelectedPackingsIDList = null;

            btnDeleteGood.Enabled = (grdData.Rows.Count > 0);
        }
Ejemplo n.º 9
0
        private void btnAddGood_Click(object sender, EventArgs e)
        {
            _SelectedPackingsIDList =
                _SelectedIDList     =
                    null;
            int  nGoodID   = 0;
            bool nFound    = false;
            Good oGoodTemp = new Good();

            if (StartForm(new frmSelectOnePacking(this, true)) != DialogResult.Yes)
            {
                _SelectedPackingsIDList = null;
                return;
            }
            else
            {
                if (_SelectedPackingsIDList == null || !_SelectedPackingsIDList.Contains(","))
                {
                    return;
                }
                oGoodTemp.PackingsIDList = "," + _SelectedPackingsIDList;
                oGoodTemp.FillData();
                if (oGoodTemp.ErrorNumber != 0 || oGoodTemp.MainTable == null || oGoodTemp.MainTable.Rows.Count == 0)
                {
                    return;
                }
            }
            RFMCursorWait.Set(true);
            foreach (DataRow rg in oGoodTemp.MainTable.Rows)
            {
                // нет ли уже такого товара?
                nGoodID = Convert.ToInt32(rg["GoodID"]);
                nFound  = false;

                foreach (DataRow drTemp in tGoodsCustoms.Rows)
                {
                    if (Convert.ToInt32(drTemp["GoodID"]) == nGoodID)
                    {
                        nFound = true;
                        if (oGoodTemp.MainTable.Rows.Count == 1)
                        {
                            RFMCursorWait.Set(false);
                            RFMMessage.MessageBoxError("Такой товар уже в списке...");
                            RFMCursorWait.Set(true);
                        }
                        break;
                    }
                }
                if (!nFound)
                {
                    // добавляем новую строку для выбранного товара
                    DataTable dtTemp = tGoodsCustoms.Clone();
                    dtTemp.Columns["GoodID"].AllowDBNull = true;
                    DataRow dr = dtTemp.Rows.Add();
                    dr["GoodID"]        = nGoodID;
                    dr["GoodName"]      = rg["GoodName"];
                    dr["GoodAlias"]     = rg["GoodAlias"];
                    dr["GoodBarCode"]   = rg["GoodBarCode"];
                    dr["Articul"]       = rg["Articul"];
                    dr["GoodGroupName"] = rg["GoodGroupName"];
                    dr["GoodBrandName"] = rg["GoodBrandName"];
                    dr["CountryName"]   = rg["CountryName"];
                    dr["Weighting"]     = rg["Weighting"];
                    dr["GoodActual"]    = rg["GoodActual"];
                    dr["Netto"]         = rg["Netto"];
                    dr["Brutto"]        = rg["Brutto"];
                    dr["Retention"]     = rg["Retention"];
                    dr["GoodERPCode"]   = rg["GoodERPCode"];

                    tGoodsCustoms.ImportRow(dr);
                }
            }
            // встать на последнюю добавленную строку
            if (nGoodID != 0)
            {
                dgvData.GridSource.Position = dgvData.GridSource.Find("GoodID", nGoodID);
                if (dgvData.GridSource.Position < 0)
                {
                    dgvData.GridSource.MoveFirst();
                }
            }
            RFMCursorWait.Set(false);
            btnDeleteGood.Enabled = (dgvData.Rows.Count > 0);
        }
Ejemplo n.º 10
0
        private void btnFilter_Click(object sender, EventArgs e)
        {
            WaitOn(this);

            oGoods.ClearError();
            oGoods.ClearFilters();

            // собираем услови¤
            if (ucSelectRecordID_GoodsGroups.IsSelectedExist)
            {
                oGoods.FilterGoodsGroupsList = ucSelectRecordID_GoodsGroups.GetIdString();
            }
            if (ucSelectRecordID_GoodsBrands.IsSelectedExist)
            {
                oGoods.FilterGoodsBrandsList = ucSelectRecordID_GoodsBrands.GetIdString();
            }

            if (txtGoodBarCode.Text.Trim().Length > 0)
            {
                oGoods.FilterGoodBarCode = txtGoodBarCode.Text.Trim();
            }
            if (txtName.Text.Trim().Length > 0)
            {
                oGoods.FilterGoodNameContext = txtName.Text.Trim();
            }

            if (chkGoodsActual.Checked)
            {
                oGoods.FilterGoodsActual = true;
            }
            if (chkPackingsActual.Checked)
            {
                oGoods.FilterPackingsActual = true;
            }

            if (nHostID.HasValue || nUserHostID.HasValue)
            {
                if (nHostID.HasValue)
                {
                    oGoods.FilterHostsList = nHostID.ToString();
                }
                if (nUserHostID.HasValue)
                {
                    oGoods.FilterHostsList = nUserHostID.ToString();
                }
            }
            else
            {
                if (ucSelectRecordID_Hosts.IsSelectedExist)
                {
                    oGoods.FilterHostsList = ucSelectRecordID_Hosts.GetIdString();
                }
            }

            if (tvwGoods.Visible && tvwGoods.TreeSource != null && tvwGoods.GetMarkedNodes() > 0)
            {
                tvwGoods.TreeSource.Filter = "IsMarked";
                tvwGoods.TreeSource.MoveFirst();
                for (int i = 0; i < tvwGoods.TreeSource.Count; i++)
                {
                    oGoods.GoodsIDList = oGoods.GoodsIDList + "," + ((DataRowView)tvwGoods.TreeSource.Current)["ID"];
                    tvwGoods.TreeSource.MoveNext();
                }
                tvwGoods.TreeSource.RemoveFilter();
            }

            grdData.DataSource = null;

            oGoods.FillData();

            if ((chkWeightNot.Checked) || (chkWeight.Checked))
            {
                DataTable dt = CopyTable(oGoods.MainTable, "dt", ((chkWeightNot.Checked) ? "not " : "") + "Weighting", "GoodAlias, GoodID, PackingID");
                oGoods.MainTable.Clear();
                oGoods.MainTable.Merge(dt);
            }

            grdData.Restore(oGoods.MainTable);

            WaitOff(this);

            /* // восстановить отмеченные записи
             * if (ucSelect != null)
             * {
             *      if (ucSelect.IsSaveMark)
             *              ucSelect.RestoreMarks(grdData);
             * }
             */

            grdData.Select();
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            _SelectedPackingID = null;

            //if (StartForm(new frmSelectOnePacking(this, false, nOwnerID)) == DialogResult.Yes)
            if (StartForm(new frmSelectOnePacking(this, false, null, oOutputDocument.HostID)) == DialogResult.Yes)
            {
                if (_SelectedPackingID != null)
                {
                    // проверить, нет ли уже такой строки
                    foreach (DataRow r in oOutputDocument.TableOutputsDocumentsGoods.Rows)
                    {
                        if (Convert.ToInt32(r["PackingID"]) == _SelectedPackingID)
                        {
                            dgvOutputsDocumentsGoods.GridSource.Position = dgvOutputsDocumentsGoods.GridSource.Find("PackingID", _SelectedPackingID);
                            if (dgvOutputsDocumentsGoods.GridSource.Position < 0)
                            {
                                dgvOutputsDocumentsGoods.GridSource.MoveFirst();
                            }
                            return;
                        }
                    }

                    Good oGood = new Good();
                    oGood.PackingID = _SelectedPackingID;
                    oGood.FillData();
                    // выбранный товар
                    DataRow rg = oGood.MainTable.Rows[0];
                    // добавляем новую строку для выбранного товара
                    DataRow dr = oOutputDocument.TableOutputsDocumentsGoods.Rows.Add(-1, -1);
                    dr["Changed"]                                    = true;
                    dr["PackingID"]                                  = _SelectedPackingID;
                    dr["GoodID"]                                     = rg["GoodID"];
                    dr["QntWished"]                                  =
                        dr["BoxWished"]                              =
                            dr["QntConfirmed"]                       =
                                dr["BoxConfirmed"]                   =
                                    dr["QntBrought"]                 =
                                        dr["BoxBrought"]             =
                                            dr["Price"]              =
                                                dr["Vat"]            =
                                                    dr["PriceNoVat"] =
                                                        0;
                    dr["GoodName"]      = rg["GoodName"];
                    dr["GoodAlias"]     = rg["GoodAlias"];
                    dr["PackingAlias"]  = rg["PackingAlias"];
                    dr["GoodBarCode"]   = rg["GoodBarCode"];
                    dr["Articul"]       = rg["Articul"];
                    dr["GoodGroupName"] = rg["GoodGroupName"];
                    dr["GoodBrandName"] = rg["GoodBrandName"];
                    dr["CountryName"]   = rg["CountryName"];
                    dr["InBox"]         = rg["InBox"];
                    dr["BoxInPal"]      = rg["BoxInPal"];
                    dr["Weighting"]     = rg["Weighting"];

                    RFMMessage.MessageBoxAttention("Не забудьте ввести цену и НДС для добавленного товара!");

                    // и встаем на эту строку
                    dgvOutputsDocumentsGoods.GridSource.Position = dgvOutputsDocumentsGoods.GridSource.Find("PackingID", _SelectedPackingID);
                    if (dgvOutputsDocumentsGoods.GridSource.Position < 0)
                    {
                        dgvOutputsDocumentsGoods.GridSource.MoveFirst();
                    }
                    // встать на найденную строку, в ячейку "Коробок дост."
                    dgvOutputsDocumentsGoods.CurrentCell = dgvOutputsDocumentsGoods.Rows[dgvOutputsDocumentsGoods.GridSource.Position].Cells["dgrcBoxBrought"];
                }

                _SelectedPackingID        = null;
                _SelectedPackingAliasText = null;
            }
        }
Ejemplo n.º 12
0
        private bool grdData_Restore()
        {
            // собираем условия

            sPartnersList = sPackingsList = null;

            // поставщики
            if (sSelectedPartnersIDList.Length > 0)
            {
                sPartnersList = sSelectedPartnersIDList;
            }
            // выбранные товары
            if (sSelectedPackingsIDList.Length > 0)
            {
                sPackingsList = sSelectedPackingsIDList;
            }

            int?nPercents = null, nMonth = null;

            if (radPercents.Checked)
            {
                nPercents = (int)numPercents.Value;
            }
            if (radMonths.Checked)
            {
                nMonth = (int)numMonths.Value;
            }
            bool bFromNow = false;

            if (radFromNow.Checked)
            {
                bFromNow = true;
            }

            WaitOn(this);

            Good oGoods = new Good();

            oGoods.FilterPackingsIDList = sPackingsList;
            oGoods.FilterGoodsActual    = true;
            oGoods.FillData();
            if (oGoods.ErrorNumber != 0)
            {
                WaitOff(this);
                return(false);
            }
            for (int i = 0; i < oGoods.MainTable.Rows.Count; i++)
            {
                if ((int)oGoods.MainTable.Rows[i]["Retention"] == 0)
                {
                    WaitOff(this);
                    RFMMessage.MessageBoxAttention("В отчет не попадут товары с нулевым сроком годности!");
                    WaitOn(this);
                    break;
                }
            }

            grdData.DataSource = null;

            oReport.ReportInputsDateValid(dtrDates.dtpBegDate.Value.Date, dtrDates.dtpEndDate.Value.Date,
                                          sPartnersList, sPackingsList,
                                          nPercents, nMonth,
                                          bFromNow);

            grdData.Restore(oReport.MainTable);

            WaitOff(this);

            grdData.Select();

            return(oReport.ErrorNumber == 0);
        }
Ejemplo n.º 13
0
        private void grdData_Restore()
        {
            oGoods.ClearError();
            oGoods.ClearFilters();

            // собираем условия
            if (ucSelectRecordID_GoodsGroups.IsSelectedExist)
            {
                oGoods.FilterGoodsGroupsList = ucSelectRecordID_GoodsGroups.GetIdString();
            }
            if (ucSelectRecordID_GoodsBrands.IsSelectedExist)
            {
                oGoods.FilterGoodsBrandsList = ucSelectRecordID_GoodsBrands.GetIdString();
            }

            if (txtGoodBarCode.Text.Trim().Length > 0)
            {
                oGoods.FilterGoodBarCode = txtGoodBarCode.Text.Trim();
            }
            if (txtName.Text.Trim().Length > 0)
            {
                oGoods.FilterGoodNameContext = txtName.Text.Trim();
            }

            if (chkGoodsActual.Checked)
            {
                oGoods.FilterGoodsActual = true;
            }
            if (chkPackingsActual.Checked)
            {
                oGoods.FilterPackingsActual = true;
            }

            if (nHostID.HasValue || nUserHostID.HasValue)
            {
                if (nHostID.HasValue)
                {
                    oGoods.FilterHostsList = nHostID.ToString();
                }
                if (nUserHostID.HasValue)
                {
                    oGoods.FilterHostsList = nUserHostID.ToString();
                }
            }
            else
            {
                if (ucSelectRecordID_Hosts.IsSelectedExist)
                {
                    oGoods.FilterHostsList = ucSelectRecordID_Hosts.GetIdString();
                }
            }

            if (tvwGoods.Visible && tvwGoods.TreeSource != null && tvwGoods.GetMarkedNodes() > 0)
            {
                tvwGoods.TreeSource.Filter = "IsMarked";
                tvwGoods.TreeSource.MoveFirst();
                for (int i = 0; i < tvwGoods.TreeSource.Count; i++)
                {
                    oGoods.FilterGoodsIDList = oGoods.FilterGoodsIDList + "," + ((DataRowView)tvwGoods.TreeSource.Current)["ID"];
                    tvwGoods.TreeSource.MoveNext();
                }
                tvwGoods.TreeSource.RemoveFilter();
            }

            oGoods.FillData();

            // артикул
            if (txtArticul.Text.Trim().Length > 0)
            {
                tTable = CopyTable(oGoods.MainTable, "tTable", "Articul LIKE '*" + txtArticul.Text.Trim().ToUpper() + "*'", "");
            }
            else
            {
                tTable = oGoods.MainTable;
            }

            grdData.Restore(tTable);
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            _SelectedPackingsIDList = null;
            int?nNewFirstPackingID = null;
            int?nNewPackingID      = null;

            if (StartForm(new frmSelectOnePacking(this, true, null, oOutputDocument.HostID)) == DialogResult.Yes)
            {
                if (_SelectedPackingsIDList != null)
                {
                    // идем по каждому выбранному товару
                    Good oGoodNew = new Good();
                    oGoodNew.PackingsIDList = _SelectedPackingsIDList;
                    oGoodNew.FillData();
                    if (oGoodNew.ErrorNumber == 0 && oGoodNew.MainTable != null &&
                        oGoodNew.MainTable.Rows.Count > 0)
                    {
                        foreach (DataRow rGNew in oGoodNew.MainTable.Rows)
                        {
                            nNewPackingID = Convert.ToInt32(rGNew["PackingID"]);
                            bool bFound = false;
                            // проверить, нет ли уже такой строки
                            foreach (DataRow r in oOutputDocument.TableOutputsDocumentsGoods.Rows)
                            {
                                if (Convert.ToInt32(r["PackingID"]) == nNewPackingID)
                                {
                                    bFound = true;
                                    break;
                                }
                            }
                            if (bFound)
                            {
                                // такой товар уже есть - переходим к след.отмеченному товару
                                continue;
                            }

                            // добавляем новую строку для выбранного товара
                            DataRow dr = oOutputDocument.TableOutputsDocumentsGoods.Rows.Add(-1, -1);
                            if (nOutputDocumentID != 0)
                            {
                                dr["OutputDocumentID"] = (int)oOutputDocument.ID;
                            }
                            dr["PackingID"]     = nNewPackingID;
                            dr["GoodID"]        = rGNew["GoodID"];
                            dr["QntWished"]     =
                                dr["BoxWished"] =
                                    dr["Price"] =
                                        0;
                            dr["GoodName"]      = rGNew["GoodName"];
                            dr["GoodAlias"]     = rGNew["GoodAlias"];
                            dr["PackingAlias"]  = rGNew["PackingAlias"];
                            dr["GoodBarCode"]   = rGNew["GoodBarCode"];
                            dr["GoodGroupName"] = rGNew["GoodGroupName"];
                            dr["GoodBrandName"] = rGNew["GoodBrandName"];
                            dr["InBox"]         = rGNew["InBox"];
                            dr["BoxInPal"]      = rGNew["BoxInPal"];
                            dr["Weighting"]     = rGNew["Weighting"];

                            if (!nNewFirstPackingID.HasValue)
                            {
                                nNewFirstPackingID = nNewPackingID;
                            }
                        }

                        // встать на последнюю найденную строку, в ячейку "Коробок зак."
                        if (nNewFirstPackingID.HasValue)
                        {
                            dgvOutputDocumentGoods.GridSource.Position = dgvOutputDocumentGoods.GridSource.Find("PackingID", nNewFirstPackingID);
                            if (dgvOutputDocumentGoods.GridSource.Position < 0)
                            {
                                dgvOutputDocumentGoods.GridSource.MoveFirst();
                            }
                            // встать на найденную строку, в ячейку "Коробок зак."
                            dgvOutputDocumentGoods.CurrentCell = dgvOutputDocumentGoods.Rows[dgvOutputDocumentGoods.GridSource.Position].Cells["dgvcBoxWished"];
                            dgvOutputDocumentGoods.Select();
                            dgvOutputDocumentGoods.Rows[dgvOutputDocumentGoods.GridSource.Position].Cells["dgvcBoxWished"].Selected = true;
                        }
                    }
                }
                _SelectedPackingsIDList   = null;
                _SelectedPackingAliasText = null;
            }
        }
Ejemplo n.º 15
0
        private void btnCellChange_Click(object sender, EventArgs e)
        {
            if (sender != null)
            {
                if (RFMMessage.MessageBoxYesNo("Изменить ячейку, в которой находится контейнер?") != DialogResult.Yes)
                {
                    return;
                }
            }

            _SelectedCellID = null;
            if (StartForm(new frmSelectOneCell(this)) == DialogResult.Yes)
            {
                if (_SelectedCellID != null)
                {
                    Cell oCellChoosen = new Cell();
                    oCellChoosen.ID = _SelectedCellID;
                    oCellChoosen.FillData();
                    if (oCellChoosen.MainTable.Rows.Count == 1)
                    {
                        // выбранная ячейка
                        DataRow r = oCellChoosen.MainTable.Rows[0];
                        // текущий контейнер
                        DataRow f = oFrame.MainTable.Rows[0];

                        // можно ли поставить этот контейнер в выбранную ячейку?
                        if (r["ForFrames"] != DBNull.Value && !(bool)r["ForFrames"])
                        {
                            RFMMessage.MessageBoxError("Выбранная ячейка не предназначена для контейнеров...");
                            return;
                        }

                        decimal nMaxPalletQnt = 0;
                        if (r["MaxPalletQnt"] == DBNull.Value)
                        {
                            if (r["StoreZoneMaxPalletQnt"] == DBNull.Value)
                            {
                                nMaxPalletQnt = 999999;
                            }
                            else
                            {
                                nMaxPalletQnt = Convert.ToDecimal(r["StoreZoneMaxPalletQnt"]);
                            }
                        }
                        else
                        {
                            nMaxPalletQnt = Convert.ToDecimal(r["MaxPalletQnt"]);
                        }

                        if (nMaxPalletQnt > 0 && nMaxPalletQnt < 999999)
                        {
                            int nFramesQntInCell = oCellChoosen.GetFramesQnt(Convert.ToInt32(oCellChoosen.ID), false);
                            int nFramesQntToCell = oCellChoosen.GetFramesQnt(Convert.ToInt32(oCellChoosen.ID), true);
                            if (nMaxPalletQnt < nFramesQntInCell + nFramesQntToCell + 1)
                            {
                                RFMMessage.MessageBoxError("Выбранная ячейка может содержать максимальное количество контейнеров: " + nMaxPalletQnt + "\n\n" +
                                                           "Сейчас в ячейке находится контейнеров: " + nFramesQntInCell.ToString() + "\n" +
                                                           "Сейчас в ячейку направляется контейнеров: " + nFramesQntToCell.ToString() + "\n\n" +
                                                           "Размещение еще одного контейнера в ячейке невозможно...");
                                return;
                            }
                        }

                        int nFramePalletTypeID = 0;
                        if (f["PalletTypeID"] != DBNull.Value)
                        {
                            nFramePalletTypeID = Convert.ToInt32(f["PalletTypeID"]);
                            if (r["PalletTypeID"] != DBNull.Value)
                            {
                                int nPalletTypeID = Convert.ToInt32(r["PalletTypeID"]);
                                if (nPalletTypeID != nFramePalletTypeID)
                                {
                                    RFMMessage.MessageBoxError("Тип поддона в ячейке не совпадает с типом поддона контейнеров...");
                                    return;
                                }
                            }
                        }

                        decimal nMaxWeight = Convert.ToDecimal(r["MaxWeight"]);
                        // пересчитать вес контейнера = вес поддона + вес коробок + вес товара
                        decimal nFrameWeight = 0;
                        Good    oGoodCalc    = new Good();
                        oGoodCalc.FillTablePalletsTypes();
                        foreach (DataRow pt in oGoodCalc.TablePalletsTypes.Rows)
                        {
                            if (nFramePalletTypeID == Convert.ToInt32(pt["ID"]))
                            {
                                nFrameWeight = Convert.ToDecimal(pt["PalletWeight"]);
                            }
                        }
                        foreach (DataRow c in oFrame.TableFramesContents.Rows)
                        {
                            if (c["Changes"].ToString() != "D")
                            {
                                oGoodCalc.PackingID = Convert.ToInt32(c["PackingID"]);
                                oGoodCalc.FillData();
                                DataRow g = oGoodCalc.MainTable.Rows[0];
                                nFrameWeight = +Convert.ToDecimal(c["BoxQnt"]) * Convert.ToDecimal(g["BoxWeight"]) +
                                               Convert.ToDecimal(c["Qnt"]) * Convert.ToDecimal(g["Netto"]);
                            }
                        }
                        if (nMaxWeight > 0 && nFrameWeight > nMaxWeight)
                        {
                            if (RFMMessage.MessageBoxYesNo("Максимально допустимый вес для выбранной ячейки: " + System.Math.Round(nMaxWeight, 0).ToString() + "\n" +
                                                           "Вес контейнера: " + System.Math.Round(nFrameWeight, 0).ToString() + ",\n" +
                                                           "что больше допустимого веса для ячейки на " + System.Math.Round((Convert.ToDecimal(nFrameWeight - nMaxWeight)), 0).ToString() + "кг \n\n" +
                                                           "Все-таки сохранить?") != DialogResult.Yes)
                            {
                                return;
                            }
                        }

                        decimal nCellHeight  = Convert.ToDecimal(r["CellHeight"]);
                        decimal nFrameHeight = Convert.ToDecimal(f["FrameHeight"]);
                        if (nCellHeight > 0 && nFrameHeight > nCellHeight)
                        {
                            if (RFMMessage.MessageBoxYesNo("Высота выбранной ячейки: " + nCellHeight.ToString() + "\n" +
                                                           "Высота контейнера: " + nFrameHeight.ToString() + ",\n" +
                                                           "что больше высоты ячейки на " + (Convert.ToDecimal(nFrameHeight - nCellHeight)).ToString() + " м \n\n" +
                                                           "Все-таки сохранить?") != DialogResult.Yes)
                            {
                                return;
                            }
                        }

                        // можем сохранять
                        oCell.ID = oCellChoosen.ID;
                        oCell.FillData();
                        lblCellAddress.Text = oCell.MainTable.Rows[0]["Address"].ToString() +
                                              " (" + oCell.MainTable.Rows[0]["StoreZoneName"].ToString() + ")";
                    }
                }
            }
        }
Ejemplo n.º 16
0
        private void frmReportPackingsTurnover_Load(object sender, EventArgs e)
        {
            oGood.PackingID = nPackingID;
            oGood.FillData();
            if (oGood.ErrorNumber != 0)
            {
                return;
            }
            if (oGood.MainTable.Rows.Count == 0)
            {
                RFMMessage.MessageBoxError("ќшибка при получении данных о товаре...");
                return;
            }

            DataRow r = oGood.MainTable.Rows[0];

            bWeighting = !Convert.IsDBNull(r["Weighting"]) && Convert.ToBoolean(r["Weighting"]) ||
                         !Convert.IsDBNull(r["InBox"]) && Convert.ToDecimal(r["InBox"]) != Convert.ToInt32(r["InBox"]);
            if (bWeighting)
            {
                numInBox.DecimalPlaces          =
                    numQntBeg.DecimalPlaces     =
                        numQntEnd.DecimalPlaces =
                            3;
                grcQntPlus.DefaultCellStyle.Format      =
                    grcQntMinus.DefaultCellStyle.Format =
                        "### ### ###.000";
            }
            else
            {
                numInBox.DecimalPlaces          =
                    numQntBeg.DecimalPlaces     =
                        numQntEnd.DecimalPlaces =
                            0;
                grcQntPlus.DefaultCellStyle.Format      =
                    grcQntMinus.DefaultCellStyle.Format =
                        "### ### ###";
            }

            txtGoodAlias.Text = oGood.MainTable.Rows[0]["GoodAlias"].ToString();
            numInBox.Value    = Convert.ToDecimal(oGood.MainTable.Rows[0]["InBox"]);

            oGoodState.ID = nGoodStateID;
            oGoodState.FillData();
            if (oGoodState.ErrorNumber != 0)
            {
                return;
            }
            if (oGoodState.MainTable.Rows.Count == 0)
            {
                RFMMessage.MessageBoxError("ќшибка при получении данных о состо¤нии товара...");
                return;
            }
            txtGoodStateName.Text = oGoodState.MainTable.Rows[0]["Name"].ToString();

            if (nOwnerID.HasValue)
            {
                oOwner.ID = nOwnerID;
                oOwner.FillData();
                if (oOwner.ErrorNumber != 0)
                {
                    return;
                }
                if (oOwner.MainTable.Rows.Count == 0)
                {
                    RFMMessage.MessageBoxError("ќшибка при получении данных о владельце/хранителе...");
                    return;
                }
                txtOwnerName.Text = oOwner.MainTable.Rows[0]["Name"].ToString();
            }

            dtrDates.dtpBegDate.Value = dDateBeg;
            dtrDates.dtpEndDate.Value = dDateEnd;
            btnFilter_Click(null, null);
        }