public virtual void DiscountCardManagement(DiscountCard discountCard, string requestCode)
        {
            if (requestCode == null)
                throw new ArgumentException("Request code", "requestCode");

            if (discountCard == null)
                throw new ArgumentNullException("discountCard", "discountCard");

            if (requestCode == Resources.OperationRequestInsert)
                InsertDiscountCard(discountCard);
            else if (requestCode == Resources.OperationRequestDuplicate)
            {
                discountCard.DiscountCardId = 0;
                InsertDiscountCard(discountCard);
            }
            else if (requestCode == Resources.OperationRequestUpdate)
                UpdateDiscountCard(discountCard);
            else
                DeleteDiscountCard(discountCard);
        }
        private void InsertDiscountCard(DiscountCard discountCard)
        {
            if (discountCard == null)
                throw new ArgumentNullException("discountCard", "DiscountCard");

            //Insert customer
            _customerDataAccess.InsertDiscountCard(discountCard);

            //Updating customer code
            discountCard.CardNumber =
                StringHelper.Right("000000000" + discountCard.DiscountCardId, 9);
            UpdateDiscountCard(discountCard);
        }
        private void UpdateDiscountCard(DiscountCard discountCard)
        {
            if (discountCard == null)
                throw new ArgumentNullException("discountCard", "DiscountCard");

            var objList = _customerDataAccess.GetDiscountCardsByCustomer(discountCard.CustomerId);
            if (objList != null)
            {
                if (objList.Count != 0)
                {
                    foreach (DiscountCard dCard in objList)
                    {
                        dCard.CustomerId = 0;
                        _customerDataAccess.UpdateDiscountCard(dCard);
                    }
                }
            }

            if (discountCard.DiscountCardId != 0)
                _customerDataAccess.UpdateDiscountCard(discountCard);
        }
        private void DeleteDiscountCard(DiscountCard discountCard)
        {
            if (discountCard == null)
                throw new ArgumentNullException("discountCard", "DiscountCard");

            _customerDataAccess.DeleteDiscountCard(discountCard);
        }
 public virtual void DeleteDiscountCard(DiscountCard discountCard)
 {
     DeleteObject(discountCard);
 }
 public virtual void UpdateDiscountCard(DiscountCard discountCard)
 {
     UpdateObject(discountCard);
 }
 //Discount card
 public virtual void InsertDiscountCard(DiscountCard discountCard)
 {
     InsertObject(discountCard);
 }
        private void btnNew_Click(object sender, EventArgs e)
        {
            if (cmbDiscountType.SelectedValue == null)
                return;

            if (txtNumCard.Text.Length == 0)
                return;

            try
            {
                if (!UserService.AllowToPerform(Resources.PermissionAddCard))
                {
                    const string briefMsg = "អំពី​សិទ្ឋិ​ប្រើ​ប្រាស់";
                    var detailMsg = Resources.MsgUserPermissionDeny;
                    using (var frmMessageBox = new FrmExtendedMessageBox())
                    {
                        frmMessageBox.BriefMsgStr = briefMsg;
                        frmMessageBox.DetailMsgStr = detailMsg;
                        frmMessageBox.IsCanceledOnly = true;
                        frmMessageBox.ShowDialog(this);
                        return;
                    }
                }

                var discountCardTypeId = Int32.Parse(cmbDiscountType.SelectedValue.ToString(), AppContext.CultureInfo);
                var discountCardTypeStr = ((AppParameter) cmbDiscountType.SelectedItem).ParameterLabel;
                var discountPercentage =
                    float.Parse(((AppParameter) cmbDiscountType.SelectedItem).ParameterValue, AppContext.CultureInfo);

                var nbrDiscountCard = Int32.Parse(txtNumCard.Text, AppContext.CultureInfo);
                for (var counter = 0; counter < nbrDiscountCard; counter++)
                {
                    var discountCard = new DiscountCard
                                           {
                                               DiscountCardTypeId = discountCardTypeId,
                                               DiscountCardTypeStr = discountCardTypeStr,
                                               DiscountPercentage = discountPercentage,
                                               ExpireDate = DateTime.Now,
                                               AllowDiscount = 1
                                           };
                    _CustomerService.DiscountCardManagement(
                        discountCard,
                        Resources.OperationRequestInsert);

                    _DiscountCardList.Add(discountCard);
                }
                dgvDiscountCard.Refresh();
                SetDiscountCardInfo();
                UpdateResultInfo();
                EnableActionButton();
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }