Esempio n. 1
0
        private void btnQualityLicenceSelect_Click(object sender, EventArgs e)
        {
            // ранее введеные значения
            Good oGoodTemp = new Good();

            oGoodTemp.FillTableGoodsQualities(null, null);
            if (oGoodTemp.ErrorNumber != 0 || oGoodTemp.TableGoodsQualities == null)
            {
                return;
            }
            if (oGoodTemp.TableGoodsQualities.Rows.Count == 0)
            {
                RFMMessage.MessageBoxError("Нет данных о декларациях...");
                return;
            }

            DataTable tdLicence = CopyTable(oGoodTemp.TableGoodsQualities, "tdLicence", "", "QualityLicence");

            if (StartForm(new frmSelectID(this, tdLicence, "QualityLicence, QualityIssuer, QualityHolder, QualityDateBeg, QualityDateEnd", "Декларация №,Выдан,Держатель,Дата нач.,Дата кон.", false)) == DialogResult.Yes)
            {
                if (_SelectedID == null)
                {
                    return;
                }
                int nGoodQualityID_Old = (int)_SelectedID;
                tdLicence.PrimaryKey = new DataColumn[] { tdLicence.Columns["ID"] };
                DataRow r = tdLicence.Rows.Find(nGoodQualityID_Old);
                if (r != null)
                {
                    txtQualityLicence.Text = r["QualityLicence"].ToString();
                    txtQualityIssuer.Text  = r["QualityIssuer"].ToString();
                    txtQualityHolder.Text  = r["QualityHolder"].ToString();
                }
            }
            _SelectedID = null;

            return;
        }
Esempio n. 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string sQualityLicence = txtQualityLicence.Text.Trim();
            string sQualityIssuer  = txtQualityIssuer.Text.Trim();
            string sQualityHolder  = txtQualityHolder.Text.Trim();

            // проверки
            if (sQualityLicence.Length == 0)
            {
                RFMMessage.MessageBoxError("Не указан номер декларации...");
                txtQualityLicence.Select();
                return;
            }
            if (sQualityIssuer.Length == 0)
            {
                RFMMessage.MessageBoxError("Не указано, кем выдана декларация...");
                txtQualityIssuer.Select();
                return;
            }
            if (sQualityHolder.Length == 0)
            {
                RFMMessage.MessageBoxError("Не указано лицо, принявшее декларацию...");
                txtQualityHolder.Select();
                return;
            }
            if (grdData.Rows.Count == 0)
            {
                if (RFMMessage.MessageBoxYesNo("Не выбрано ни одного товара...\n" +
                                               "Все-таки сохранить?") != DialogResult.Yes)
                {
                    return;
                }
            }

            // уникальность номера
            RFMCursorWait.Set(true);

            Good oGoodTemp = new Good();

            oGoodTemp.FillTableGoodsQualities(null, null);
            foreach (DataRow dr in oGoodTemp.TableGoodsQualities.Rows)
            {
                if (dr["QualityLicence"].ToString().Trim().ToUpper() == sQualityLicence.ToUpper() &&
                    (!nGoodQualityID.HasValue || (int)nGoodQualityID != (int)dr["ID"]))
                {
                    RFMCursorWait.Set(false);
                    RFMMessage.MessageBoxError("Такая декларация уже есть...");
                    txtQualityLicence.Select();
                    return;
                }
            }
            RFMCursorWait.Set(false);

            DateTime?dDateBeg = null, dDateEnd = null;

            if (!dtrDates.dtpBegDate.IsEmpty)
            {
                dDateBeg = dtrDates.dtpBegDate.Value;
            }
            if (!dtrDates.dtpEndDate.IsEmpty)
            {
                dDateEnd = dtrDates.dtpEndDate.Value;
            }

            // собственно сохранение
            oGood.ClearError();
            oGood.SaveGoodQuality(ref nGoodQualityID, sQualityLicence, sQualityIssuer, sQualityHolder, dDateBeg, dDateEnd, tGoodsQualities);
            if (oGood.ErrorNumber == 0)
            {
                // код добавленной записи
                if (nGoodQualityID.HasValue)
                {
                    MotherForm.GotParam = new object[] { (int)nGoodQualityID };
                    DialogResult        = DialogResult.Yes;
                    Dispose();
                }
            }
        }