Пример #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            revenue _revenue = new revenue();

            if (IsEdit == true)
            {
                _revenue = _db.GetRevenueById(this.RecordId, databaseId);
            }
            _revenue.Users           = Convert.ToInt32(txtUsers.Text);
            _revenue.PriceFixedUntil = rdPriceFixedUnitl.Value;
            _revenue.RevenueAmount   = Convert.ToDecimal(txtRevenue.Text);
            _revenue.customerid      = CustomerId;
            _revenue.Year            = Convert.ToInt16(cboYear.Text);
            _revenue.isActive        = true;
            _revenue.CreatedDate     = DateTime.Now;
            _revenue.databaseID      = databaseId;
            if (IsEdit == false)
            {
                _db.AddToRevenue(_revenue);
                _db.SaveChanges();
                MessageBox.Show("Revenue Saved", "Revenue has been Created ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                _db.SaveRevenue(_revenue);
                _db.SaveChanges();
                MessageBox.Show("Revenue  Saved", "Revenue has been updated ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            this.Close();
        }