Exemplo n.º 1
0
        public override void SaveEntity()
        {
            this.service.ServiceAmount = Convert.ToDecimal(this.frmServicesManagement.txtDetServiceAmount.Value);
            this.service.ServiceNumber = Convert.ToInt32(this.frmServicesManagement.txtDetServiceNumber.Value);
            this.service.StaffNames    = string.Join(", ", this.frmServicesManagement.sccDetStaff.Values.Select(x => x.Fullname).ToArray());
            this.service.Authorized    = this.frmServicesManagement.uchkDetAuthorized.Checked;
            this.service.Processed     = this.frmServicesManagement.uchkDetProcessed.Checked;

            foreach (ServiceStaff serviceStaff in this.service.ServiceStaff)
            {
                EntitiesUtil.SetAsDeleted(serviceStaff);
            }

            foreach (Staff staff in this.frmServicesManagement.sccDetStaff.Values)
            {
                ServiceStaff serviceStaff = new ServiceStaff();

                serviceStaff.Service = service;
                serviceStaff.Staff   = staff;

                this.service.ServiceStaff.Add(serviceStaff);
            }

            this.srvService.SaveOrUpdate(this.service);
        }
        public override void SaveEntity()
        {
            this.commissionPayment.Comments      = this.frmCommissionPayment.txtDetComments.Value as string;
            this.commissionPayment.Amount        = Convert.ToDecimal(this.frmCommissionPayment.txtDetAmount.Value);
            this.commissionPayment.Month         = Convert.ToInt32(this.frmCommissionPayment.uceDetMonth.Value);
            this.commissionPayment.Year          = Convert.ToInt32(this.frmCommissionPayment.txtDetYear.Value);
            this.commissionPayment.IsSalesRetail = this.frmCommissionPayment.uchkDetIsSalesRetail.Checked;
            this.commissionPayment.StaffNames    = string.Join(", ",
                                                               this.frmCommissionPayment.sccDetStaff.Values.Select(x => x.Fullname).ToArray());

            foreach (CommissionPaymentStaff commissionPaymentStaff in this.commissionPayment.CommissionPaymentStaffs)
            {
                EntitiesUtil.SetAsDeleted(commissionPaymentStaff);
            }

            foreach (Staff staff in this.frmCommissionPayment.sccDetStaff.Values)
            {
                CommissionPaymentStaff commissionPaymentStaff = new CommissionPaymentStaff();

                commissionPaymentStaff.CommissionPayment = this.commissionPayment;
                commissionPaymentStaff.Staff             = staff;

                this.commissionPayment.CommissionPaymentStaffs.Add(commissionPaymentStaff);
            }

            this.srvCommissionPayment.SaveOrUpdate(this.commissionPayment);
        }