コード例 #1
0
        private void btnGo_Click(object sender, EventArgs e)
        {
            // возвращаем код выбранного товара/упаковки в родительскую форму, поле _SelectedPackingID

            string _SelectedPackingsIDList    = null;
            int?   _SelectedPackingID         = null;
            string _SelectedPackingsAliasText = "";

            if (grdData.Rows.Count > 0)
            {
                if (ucSelect != null)
                {
                    ucSelect.SaveData(grdData, "GoodAlias", useCheck);
                }
                else
                {
                    if (useCheck && grdData.IsCheckerShow)
                    {
                        // список ID
                        _SelectedPackingsIDList    = "";
                        _SelectedPackingsAliasText = "";

                        DataView dMarked = new DataView(oGoods.MainTable);
                        dMarked.RowFilter = "IsMarked = true";
                        dMarked.Sort      = grdData.GridSource.Sort;
                        int i = 0;
                        int nFirstCntRecords = 3;                         // количество первых записей дл¤ наборного текстового значени¤
                        foreach (DataRowView r in dMarked)
                        {
                            if (!Convert.IsDBNull(r["PackingID"]))
                            {
                                _SelectedPackingsIDList += r["PackingID"].ToString() + ",";

                                if (i < nFirstCntRecords)
                                {
                                    _SelectedPackingsAliasText += r["PackingAlias"].ToString().Trim() + ", ";
                                }
                                else
                                {
                                    if (i == nFirstCntRecords)
                                    {
                                        _SelectedPackingsAliasText += "...";
                                    }
                                }
                                i++;
                            }
                        }
                        if (_SelectedPackingsIDList.Length == 0)
                        {
                            // нет отметок - берем текущую запись
                            if (grdData.CurrentRow != null)
                            {
                                _SelectedPackingsIDList    = grdData.CurrentRow.Cells["grcPackingID"].Value.ToString() + ",";
                                _SelectedPackingsAliasText = grdData.CurrentRow.Cells["grcGoodAlias"].Value.ToString().Trim();
                            }
                        }

                        // приводим наборное текстовое поле к виду: (5) раз, два, три, ...
                        if (_SelectedPackingsIDList.Length == 0)
                        {
                            _SelectedPackingsIDList    = null;
                            _SelectedPackingsAliasText = "";
                        }
                        else
                        {
                            _SelectedPackingsAliasText = _SelectedPackingsAliasText.Trim();
                            if (_SelectedPackingsAliasText.Substring(_SelectedPackingsAliasText.Length - 1, 1) == ",")
                            {
                                _SelectedPackingsAliasText = _SelectedPackingsAliasText.Substring(0, _SelectedPackingsAliasText.Length - 1);
                            }
                            _SelectedPackingsAliasText = "(" + RFMUtilities.Occurs(_SelectedPackingsIDList, ",").ToString() + "): " +
                                                         _SelectedPackingsAliasText;
                        }

                        if (bFromParentForm && parentForm != null)
                        {
                            RFMUtilities.SetFormField(parentForm, "_SelectedPackingsIDList", _SelectedPackingsIDList);
                            RFMUtilities.SetFormField(parentForm, "_SelectedPackingsAliasText", _SelectedPackingsAliasText);
                        }
                    }
                    else
                    {
                        // ID текущей строки
                        if (grdData.CurrentRow != null)
                        {
                            _SelectedPackingID         = (int)grdData.CurrentRow.Cells["grcPackingID"].Value;
                            _SelectedPackingsAliasText = grdData.CurrentRow.Cells["grcGoodAlias"].Value.ToString().Trim();
                        }

                        if (bFromParentForm && parentForm != null)
                        {
                            RFMUtilities.SetFormField(parentForm, "_SelectedPackingID", _SelectedPackingID);
                            RFMUtilities.SetFormField(parentForm, "_SelectedPackingsAliasText", _SelectedPackingsAliasText);
                        }
                    }
                }
            }
            else
            {
                RFMMessage.MessageBoxInfo("Ќе выбрано ни одного товара...");
            }

            DialogResult = DialogResult.Yes;
            Dispose();
        }
コード例 #2
0
        private void btnGo_Click(object sender, EventArgs e)
        {
            // возвращаем код/список кодов заказов в родительскую форму

            string _SelectedOutputsDocumentsIDList = null;
            int?   _SelectedOutputDocumentID       = null;
            string _SelectedOutputsDocumentsText   = "";

            if (grdOutputsDocuments.Rows.Count > 0)
            {
                if (useCheck && grdOutputsDocuments.IsCheckerShow)
                {
                    // список ID
                    _SelectedOutputsDocumentsIDList = "";
                    _SelectedOutputsDocumentsText   = "";

                    DataView dMarked = new DataView(oOutputDocumentList.MainTable);
                    dMarked.RowFilter = "IsMarked = true";
                    dMarked.Sort      = grdOutputsDocuments.GridSource.Sort;
                    int i = 0;
                    foreach (DataRowView r in dMarked)
                    {
                        if (!Convert.IsDBNull(r["ID"]))
                        {
                            _SelectedOutputsDocumentsIDList += r["ID"].ToString() + ",";

                            if (i < nFirstCntRecords)
                            {
                                _SelectedOutputsDocumentsText += Convert.ToDateTime(r["DateOutput"]).ToString("dd.MM.yyyy") + " " + r["PartnerTargetName"].ToString() + ", ";
                            }
                            else
                            {
                                if (i == nFirstCntRecords)
                                {
                                    _SelectedOutputsDocumentsText += "...";
                                }
                            }
                            i++;
                        }
                    }
                    if (_SelectedOutputsDocumentsIDList.Length == 0)
                    {
                        // нет отметок - берем текущую запись
                        if (grdOutputsDocuments.CurrentRow != null)
                        {
                            _SelectedOutputsDocumentsIDList = grdOutputsDocuments.CurrentRow.Cells["grcOutputsDocuments_ID"].Value.ToString() + ",";
                            _SelectedOutputsDocumentsText   = grdOutputsDocuments.CurrentRow.Cells["grcOutputsDocuments_DateOutput"].Value.ToString().Substring(0, 10) + " " +
                                                              grdOutputsDocuments.CurrentRow.Cells["grcOutputsDocuments_PartnerTargetName"].Value.ToString().Trim();
                        }
                    }

                    // приводим наборное текстовое поле к виду: (5) раз, два, три, ...
                    if (_SelectedOutputsDocumentsIDList.Length == 0)
                    {
                        _SelectedOutputsDocumentsIDList = null;
                        _SelectedOutputsDocumentsText   = "";
                    }
                    else
                    {
                        _SelectedOutputsDocumentsText = _SelectedOutputsDocumentsText.Trim();
                        if (_SelectedOutputsDocumentsText.Substring(_SelectedOutputsDocumentsText.Length - 1, 1) == ",")
                        {
                            _SelectedOutputsDocumentsText = _SelectedOutputsDocumentsText.Substring(0, _SelectedOutputsDocumentsText.Length - 1);
                        }
                        _SelectedOutputsDocumentsText = "(" + RFMUtilities.Occurs(_SelectedOutputsDocumentsIDList, ",").ToString() + "): " +
                                                        _SelectedOutputsDocumentsText;
                    }

                    RFMUtilities.SetFormField(parentForm, "_SelectedOutputsDocumentsIDList", _SelectedOutputsDocumentsIDList);
                    RFMUtilities.SetFormField(parentForm, "_SelectedOutputsDocumentsText", _SelectedOutputsDocumentsText);
                }
                else
                {
                    // ID текущей строки
                    if (grdOutputsDocuments.CurrentRow != null)
                    {
                        _SelectedOutputDocumentID     = Convert.ToInt32(grdOutputsDocuments.CurrentRow.Cells["grcOutputsDocuments_ID"].Value);
                        _SelectedOutputsDocumentsText = grdOutputsDocuments.CurrentRow.Cells["grcOutputsDocuments_DateOutput"].Value.ToString().Substring(0, 10) + " " +
                                                        grdOutputsDocuments.CurrentRow.Cells["grcOutputsDocuments_PartnerTargetName"].Value.ToString().Trim();
                    }

                    RFMUtilities.SetFormField(parentForm, "_SelectedOutputDocumentID", _SelectedOutputDocumentID);
                    RFMUtilities.SetFormField(parentForm, "_SelectedOutputsDocumentsText", _SelectedOutputsDocumentsText);
                }
            }
            else
            {
                RFMMessage.MessageBoxInfo("Не выбрано ни одного расходного документа...");
            }

            DialogResult = DialogResult.Yes;
            Dispose();
        }