示例#1
0
        public void Add(MembershipData md)
        {
            if (!this._dict.TryGetValue(md.EmployeeId, out List <MembershipData> list))
            {
                list = new List <MembershipData>();
                this._dict.Add(md.EmployeeId, list);
            }

            list.Add(md);
        }
示例#2
0
 public void AddMembership(MembershipData md)
 {
     this.Memberships.Add(md);
     md.CalculatePartOfDay();
     this.GroupTotalDays += md.PartOfDay;
 }
示例#3
0
        private async Task <ShareData> GetShareData(Payment payment, SqlConnection conn, SqlTransaction tx)
        {
            ShareData share = new ShareData();
            Dictionary <int, GroupShareData> groups = new Dictionary <int, GroupShareData>();

            using (SqlCommand cmd = _sqlServer.GetSpCommand("payment.LoadShareData", conn, tx))
            {
                cmd.AddIntParam("@PlaceId", payment.PlaceId);
                cmd.AddIntParam("@EmployeeId", payment.EmployeeId);
                cmd.AddDateTime2Param("@PaymentDateTime", payment.PaymentDateTime);
                cmd.AddBitParam("@IsTimeSpecified", payment.IsTimeSpecified);

                SqlParameter PaymentLimitParam         = cmd.AddDecimalParam("@PaymentLimit", 18, 2).Output();
                SqlParameter SystemCommissionParam     = cmd.AddDecimalParam("@SystemCommission", 4, 2).Output();
                SqlParameter IsPlaceActiveParam        = cmd.AddIntParam("@IsPlaceActive").Output();
                SqlParameter PlaceDisplayNameParam     = cmd.AddNVarCharParam("@PlaceDisplayName", 100).Output();
                SqlParameter ShareSchemeHistoryIdParam = cmd.AddIntParam("@ShareSchemeHistoryId").Output();
                SqlParameter PersonalShareParam        = cmd.AddTinyIntParam("@PersonalShare").Output();
                SqlParameter EmployeeFirstNameParam    = cmd.AddNVarCharParam("@EmployeeFirstName", 50).Output();
                SqlParameter EmployeeLastNameParam     = cmd.AddNVarCharParam("@EmployeeLastName", 50).Output();
                SqlParameter EmployeeIsFiredParam      = cmd.AddBitParam("@EmployeeIsFired").Output();

                using (SqlDataReader dr = await cmd.ExecuteReaderAsync())
                {
                    while (dr.Read())
                    {
                        GroupShareData gdata = new GroupShareData();
                        gdata.Name   = dr.GetString("Name");
                        gdata.Id     = dr.GetInt32("GroupId");
                        gdata.Weight = dr.GetByte("GroupWeight");
                        groups.Add(gdata.Id, gdata);
                        share.Groups.Add(gdata);
                    }

                    dr.NextResult();

                    while (dr.Read())
                    {
                        MembershipData md = new MembershipData();
                        md.EmployeeId    = dr.GetInt32("EmployeeId");
                        md.GroupId       = dr.GetInt32("GroupId");
                        md.BeginDateTime = dr.GetDateTime("BeginDateTime");
                        md.EndDateTime   = dr.GetDateTime("EndDateTime");
                        md.IsManager     = dr.GetBoolean("IsManager");
                        md.IsOwner       = dr.GetBoolean("IsOwner");
                        share.Memberships.Add(md);

                        groups[md.GroupId].AddMembership(md);
                    }
                }

                share.PaymentLimit         = PaymentLimitParam.GetDecimal();
                share.SystemCommission     = SystemCommissionParam.GetDecimal();
                share.Place.Id             = payment.PlaceId;
                share.Place.Name           = PlaceDisplayNameParam.Value.ToString();
                share.Place.IsActive       = (IsPlaceActiveParam.GetInt32() != 0);
                share.ShareSchemeHistoryId = ShareSchemeHistoryIdParam.GetInt32();
                share.PersonalShare        = PersonalShareParam.GetByte();

                if (payment.EmployeeId.HasValue)
                {
                    share.Receiver           = new ReceiverData();
                    share.Receiver.Id        = payment.EmployeeId.Value;
                    share.Receiver.FirstName = EmployeeFirstNameParam.Value.ToString();
                    share.Receiver.LastName  = EmployeeLastNameParam.Value.ToString();
                    share.Receiver.IsFired   = EmployeeIsFiredParam.GetBooleanOrDefault();
                }
            }

            return(share);
        }