コード例 #1
0
        //Изменить надбавку пенсионеру
        public bool ModifyPensAllwnc(RefPensAllwnc pensAllwnc, out string error)
        {
            error = string.Empty;
            if (conn == null)
            {
                error = "conn == null";
                return(false);
            }
            if (pensAllwnc == null)
            {
                error = "pensAllwnc == null";
                return(false);
            }
            SqlCommand command = new SqlCommand(spRefPensAllwncUpdate, conn);

            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Connection  = conn;

            command.Parameters.AddWithValue("@inRefPensAllwnc_Id", pensAllwnc.RefPensAllwnc_Id);
            command.Parameters.AddWithValue("@inRefPensAllwnc_Cd", pensAllwnc.RefPensAllwnc_Cd);
            command.Parameters.AddWithValue("@inRefPensAllwnc_Nm", pensAllwnc.RefPensAllwnc_Nm);
            command.Parameters.AddWithValue("@inRefPensAllwnc_Pct", pensAllwnc.RefPensAllwnc_Pct);
            command.Parameters.AddWithValue("@inRefPensAllwnc_Flg", pensAllwnc.RefPensAllwnc_Flg);

            try
            {
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
            return(true);
        }
コード例 #2
0
        //Обновление строки
        private void UpdateRecord()
        {
            if (dgvPensAllwnc.CurrentRow == null)
            {
                return;
            }
            string          error;
            v_RefPensAllwnc v_pensAllwnc = dgvPensAllwnc.CurrentRow.DataBoundItem as v_RefPensAllwnc;

            if (v_pensAllwnc == null)
            {
                MessageBox.Show("Не знайдена надбавка для оновлення", "Помилка");
                return;
            }

            fmRefPensAllwncEdit fmEdit = new fmRefPensAllwncEdit(EnumFormMode.Edit, "Зміна надбавки");

            fmEdit.SetData(v_pensAllwnc);
            if (fmEdit.ShowDialog() == DialogResult.OK)
            {
                RefPensAllwnc pensAllwnc = fmEdit.GetData();
                if (!_repository.ModifyPensAllwnc(pensAllwnc, out error))
                {
                    MessageBox.Show("Помилка оновлення надбавки.\nТехнічна інформація: " + error, "Помилка");
                    return;
                }
                RefreshTable();
            }
        }
コード例 #3
0
        private void tbCd_Validating(object sender, CancelEventArgs e)
        {
            if (_cmbParams.tbCd.Text == string.Empty)
            {
                _cmbParams.ClearParams();
                return;
            }
            RefPensAllwnc allwnc = _cmbParams.pensAllwncs.FirstOrDefault(rec => rec.RefPensAllwnc_Cd == _cmbParams.tbCd.Text);

            if (allwnc != null)
            {
                _cmbParams.RefPensAllwnc_Id = allwnc.RefPensAllwnc_Id;

                if (_cmbParams.tbCd != null)
                {
                    _cmbParams.tbCd.Text = allwnc.RefPensAllwnc_Cd;
                }

                if (_cmbParams.tbNm != null)
                {
                    _cmbParams.tbNm.Text = allwnc.RefPensAllwnc_Nm;
                }

                if (_cmbParams.tbPct != null)
                {
                    _cmbParams.tbPct.Text = allwnc.RefPensAllwnc_Pct.ToString("0.00");
                }
            }
            else
            {
                _cmbParams.ClearParams();
                btn_Click(sender, e);
            }
        }
コード例 #4
0
        public void ReadCombobox(int id)
        {
            if (_cmbParams == null)
            {
                return;
            }
            if (_cmbParams.pensAllwncs == null)
            {
                return;
            }

            RefPensAllwnc allwnc = _cmbParams.pensAllwncs.FirstOrDefault(rec => rec.RefPensAllwnc_Id == id);

            if (allwnc == null)
            {
                _cmbParams.ClearParams();
                return;
            }
            _cmbParams.RefPensAllwnc_Id = allwnc.RefPensAllwnc_Id;

            if (_cmbParams.tbCd != null)
            {
                _cmbParams.tbCd.Text = allwnc.RefPensAllwnc_Cd;
            }

            if (_cmbParams.tbNm != null)
            {
                _cmbParams.tbNm.Text = allwnc.RefPensAllwnc_Nm;
            }

            if (_cmbParams.tbPct != null)
            {
                _cmbParams.tbPct.Text = allwnc.RefPensAllwnc_Pct.ToString("0.00");
            }
        }
コード例 #5
0
        public RefPensAllwnc GetData()
        {
            if (dgvPensAllwnc.CurrentRow == null)
            {
                return(null);
            }

            RefPensAllwnc allowance = dgvPensAllwnc.CurrentRow.DataBoundItem as RefPensAllwnc;

            return(allowance);
        }
コード例 #6
0
        public void SetData(RefPensAllwnc pensAllwnc)
        {
            if (pensAllwnc == null)
            {
                return;
            }

            _id           = pensAllwnc.RefPensAllwnc_Id;
            tbCd.Text     = pensAllwnc.RefPensAllwnc_Cd;
            tbNm.Text     = pensAllwnc.RefPensAllwnc_Nm;
            tbPct.Text    = pensAllwnc.RefPensAllwnc_Pct.ToString("0.00");
            cbUse.Checked = (pensAllwnc.RefPensAllwnc_Flg & (int)EnumPensAllwnc_Flg.ALLWNC_NOTUSE) > 0 ? false : true;
        }
コード例 #7
0
        //Вставка строки
        private void InsertRecord()
        {
            fmRefPensAllwncEdit fmEdit = new fmRefPensAllwncEdit(EnumFormMode.Insert, "Створення надбавки");

            if (fmEdit.ShowDialog() == DialogResult.OK)
            {
                string        error;
                RefPensAllwnc pensAllwnc = fmEdit.GetData();

                if (!_repository.AddPensAllwnc(pensAllwnc, out error))
                {
                    MessageBox.Show("Помилка додавання.\nТехнічна інформація: " + error, "Помилка");
                    return;
                }
                RefreshTable();
            }
        }
コード例 #8
0
        //Вставка строки
        private void InsertRecord()
        {
            fmRefPensAllwncEdit fmEdit = new fmRefPensAllwncEdit(EnumFormMode.Insert, "Створення надбавки пенсіонеру");

            if (fmEdit.ShowDialog() == DialogResult.OK)
            {
                string        error;
                RefPensAllwnc pensAllwnc = fmEdit.GetData();
                int           id         = _repository.AddPensAllwnc(pensAllwnc, out error);
                if (id == 0)
                {
                    MessageBox.Show("Помилка додавання рядка.\nТехнічна інформація: " + error, "Помилка");
                    return;
                }
                RefreshTable();
                dgvPensAllwnc.SetPositionRow <v_RefPensAllwnc>("RefPensAllwnc_Id", id.ToString());
            }
        }
コード例 #9
0
        //Добавить надбавку пенсионеру
        public int AddPensAllwnc(RefPensAllwnc pensAllwnc, out string error)
        {
            error = string.Empty;
            if (pensAllwnc == null)
            {
                error = "pensAllwnc == null";
                return(0);
            }
            if (conn == null)
            {
                error = "conn == null";
                return(0);
            }
            SqlCommand command = new SqlCommand(spRefPensAllwncInsert, conn);

            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Connection  = conn;
            command.Parameters.AddWithValue("@inRefPensAllwnc_Cd", pensAllwnc.RefPensAllwnc_Cd);
            command.Parameters.AddWithValue("@inRefPensAllwnc_Nm", pensAllwnc.RefPensAllwnc_Nm);
            command.Parameters.AddWithValue("@inRefPensAllwnc_Pct", pensAllwnc.RefPensAllwnc_Pct);
            command.Parameters.AddWithValue("@inRefPensAllwnc_Flg", pensAllwnc.RefPensAllwnc_Flg);
            // определяем выходной параметр
            SqlParameter outId = new SqlParameter
            {
                ParameterName = "outId",
                Direction     = ParameterDirection.Output,
                SqlDbType     = SqlDbType.Int
            };

            command.Parameters.Add(outId);
            try
            {
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(0);
            }
            int id = 0;

            int.TryParse(command.Parameters["outId"].Value.ToString(), out id);
            return(id);
        }
コード例 #10
0
        private void FillDataRec(SqlDataReader reader, RefPensAllwnc pensAllwnc)
        {
            int     resInt     = 0;
            decimal resDecimal = 0;

            if (int.TryParse(reader["RefPensAllwnc_Id"].ToString(), out resInt))
            {
                pensAllwnc.RefPensAllwnc_Id = resInt;
            }
            pensAllwnc.RefPensAllwnc_Cd = reader["RefPensAllwnc_Cd"].ToString();
            pensAllwnc.RefPensAllwnc_Nm = reader["RefPensAllwnc_Nm"].ToString();
            if (decimal.TryParse(reader["RefPensAllwnc_Pct"].ToString(), out resDecimal))
            {
                pensAllwnc.RefPensAllwnc_Pct = resDecimal;
            }
            if (int.TryParse(reader["RefPensAllwnc_Flg"].ToString(), out resInt))
            {
                pensAllwnc.RefPensAllwnc_Flg = resInt;
            }
        }
コード例 #11
0
        //Получить надбавки пенсионеру
        public List <RefPensAllwnc> GetAllPensAllwnc(out string error)
        {
            error = string.Empty;

            List <RefPensAllwnc> refPensAllwncs = new List <RefPensAllwnc>();

            if (conn == null)
            {
                error = "conn == null";
                return(refPensAllwncs);
            }

            SqlCommand command = new SqlCommand(spRefPensAllwncSelect, conn);

            command.CommandType = System.Data.CommandType.StoredProcedure;
            SqlDataReader reader = null;

            try
            {
                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    RefPensAllwnc refPensAllwnc = new RefPensAllwnc();
                    FillDataRec(reader, refPensAllwnc);
                    refPensAllwncs.Add(refPensAllwnc);
                }
            }
            catch (Exception exc)
            {
                error = exc.Message;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(refPensAllwncs);
        }
コード例 #12
0
        //Получить надбавку пенсионеру по id
        public RefPensAllwnc GetPensAllwncById(int id, out string error)
        {
            error = string.Empty;
            RefPensAllwnc resPensAllwnc = null;

            if (conn == null)
            {
                error = "conn == null";
                return(null);
            }
            SqlCommand command = new SqlCommand(spRefPensAllwncSelect, conn);

            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Connection  = conn;
            command.Parameters.AddWithValue("@inRefPensAllwnc_Id", id);
            SqlDataReader reader = null;

            try
            {
                reader = command.ExecuteReader();
                if (reader.HasRows)
                {
                    reader.Read();
                    resPensAllwnc = new RefPensAllwnc();
                    FillDataRec(reader, resPensAllwnc);
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(resPensAllwnc);
        }
コード例 #13
0
        private void btn_Click(object sender, EventArgs e)
        {
            fmCmbPensAllwnc fmCmbAllwnc = new fmCmbPensAllwnc(_cmbParams.pensAllwncs);

            if (fmCmbAllwnc.ShowDialog() == DialogResult.OK)
            {
                RefPensAllwnc allwnc = fmCmbAllwnc.GetData();
                _cmbParams.RefPensAllwnc_Id = allwnc.RefPensAllwnc_Id;
                if (_cmbParams.tbCd != null)
                {
                    _cmbParams.tbCd.Text = allwnc.RefPensAllwnc_Cd;
                }
                if (_cmbParams.tbPct != null)
                {
                    _cmbParams.tbPct.Text = allwnc.RefPensAllwnc_Pct.ToString("0.00");
                }
                if (_cmbParams.tbNm != null)
                {
                    _cmbParams.tbNm.Text = allwnc.RefPensAllwnc_Nm;
                }
            }
        }
コード例 #14
0
        public RefPensAllwnc GetData()
        {
            RefPensAllwnc pensAllwnc = new RefPensAllwnc();

            pensAllwnc.RefPensAllwnc_Id = _id;
            pensAllwnc.RefPensAllwnc_Cd = tbCd.Text;
            pensAllwnc.RefPensAllwnc_Nm = tbNm.Text;
            decimal resDec = 0;

            if (decimal.TryParse(tbPct.Text, out resDec))
            {
                pensAllwnc.RefPensAllwnc_Pct = resDec;
            }
            if (cbUse.Checked)
            {
                pensAllwnc.RefPensAllwnc_Flg &= ~(int)EnumPensAllwnc_Flg.ALLWNC_NOTUSE;
            }
            else
            {
                pensAllwnc.RefPensAllwnc_Flg |= (int)EnumPensAllwnc_Flg.ALLWNC_NOTUSE;
            }
            return(pensAllwnc);
        }