⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 contactaccessor.cs

📁 MIED是用于个人帐务管理的小型软件
💻 CS
📖 第 1 页 / 共 2 页
字号:
            CommandFactory.AddCommandParameter(command, "@" + ContactSchema.FieldNote, note);

            CommandHelper.ExecuteCommand(command);
        }

        protected override CommandFieldValueList BuildPairList(Entity entity)
        {
            Contact contact = (Contact)entity;
            ContactRecord contactRecord = contact.ContactRecord;

            CommandFieldValueList list = new CommandFieldValueList(contactRecord.ID);

            list.Add(ContactSchema.FieldContactType, (int)contactRecord.ContactType);

            list.Add(ContactSchema.FieldBillToFirstName, contactRecord.BilltoFirstName == null ? "" : contactRecord.BilltoFirstName);
            list.Add(ContactSchema.FieldBillToLastName, contactRecord.BilltoLastName == null ? "" : contactRecord.BilltoLastName);
            list.Add(ContactSchema.FieldBillToCompany, contactRecord.BilltoCompany == null ? "" : contactRecord.BilltoCompany);

            list.Add(ContactSchema.FieldBillToAddress1, contactRecord.BilltoAddressLine1);
            list.Add(ContactSchema.FieldBillToAddress2, contactRecord.BilltoAddressLine2);
            list.Add(ContactSchema.FieldBillToCity, contactRecord.BilltoCity);
            list.Add(ContactSchema.FieldBillToState, contactRecord.BilltoState);
            list.Add(ContactSchema.FieldBillToZip, contactRecord.BilltoZip);
            list.Add(ContactSchema.FieldBillToCountry, contactRecord.BilltoCountry);

            list.Add(ContactSchema.FieldShipToFirstName, contactRecord.ShiptoFirstName);
            list.Add(ContactSchema.FieldShipToLastName, contactRecord.ShiptoLastName);
            list.Add(ContactSchema.FieldShipToCompany, contactRecord.ShiptoCompany);
            list.Add(ContactSchema.FieldShipToAddress1, contactRecord.ShiptoAddressLine1);
            list.Add(ContactSchema.FieldShipToAddress2, contactRecord.ShiptoAddressLine2);
            list.Add(ContactSchema.FieldShipToCity, contactRecord.ShiptoCity);
            list.Add(ContactSchema.FieldShipToState, contactRecord.ShiptoState);
            list.Add(ContactSchema.FieldShipToZip, contactRecord.ShiptoZip);
            list.Add(ContactSchema.FieldShipToCountry, contactRecord.ShiptoCountry);

            list.Add(ContactSchema.FieldPhoneNumber1, contactRecord.PhoneNumber1);
            list.Add(ContactSchema.FieldPhoneNumber2, contactRecord.PhoneNumber2);
            list.Add(ContactSchema.FieldContact, contactRecord.ContactName);
            list.Add(ContactSchema.FieldFax, contactRecord.Fax);
            list.Add(ContactSchema.FieldEmail, contactRecord.Email);
            list.Add(ContactSchema.FieldLastActivity, contactRecord.LastActivity);
            list.Add(ContactSchema.FieldNote, contactRecord.Note);

            list.Add(ContactSchema.FieldRepeatBilling, contactRecord.RepeatBilling);
            list.Add(ContactSchema.FieldCustomerDiscount, contactRecord.CustomerDiscount);
            list.Add(ContactSchema.FieldCustomerCreditLimit, contactRecord.CustomerCreditLimit);
            list.Add(ContactSchema.FieldCustomerActiveStatus, contactRecord.CustomerActiveStatus);
            list.Add(ContactSchema.FieldCustomerTax1, contactRecord.CustomerTax1);
            list.Add(ContactSchema.FieldCustomerTax2, contactRecord.CustomerTax2);
            list.Add(ContactSchema.FieldCustomerCredit, contactRecord.CustomerCredit);
            list.Add(ContactSchema.FieldCustomerCreditDate, contactRecord.CustomerCreditDate);

            list.Add(ContactSchema.FieldVendorDiscount, contactRecord.VendorDiscount);
            list.Add(ContactSchema.FieldVendorCreditLimit, contactRecord.VendorCreditLimit);
            list.Add(ContactSchema.FieldVendorActiveStatus, contactRecord.VendorActiveStatus);
            list.Add(ContactSchema.FieldVendorTax1, contactRecord.VendorTax1);
            list.Add(ContactSchema.FieldVendorTax2, contactRecord.VendorTax2);
            list.Add(ContactSchema.FieldVendorCredit, contactRecord.VendorCredit);
            list.Add(ContactSchema.FieldVendorCreditDate, contactRecord.VendorCreditDate);

            list.Add(ContactSchema.FieldCreditCardID, contactRecord.CreditCard.ID);

            return list;
        }

        protected override DbCommand CommandSelectEntity()
        {
            DbCommand command = CommandFactory.SelectAll(this.Database.Connection, ContactSchema.TableName);
            CommandFactory.WhereAndListOR(command, ContactSchema.FieldContactType, (int)this.ContactType, ContactSchema.FieldContactType, (int)ContactType.CustomerAndVendor);
            return command;
        }

        protected override void CommandSaveSupplement(DbCommand command)
        {
            SqlCECommandHelper.SetParameterType_NText(command, "@" + ContactSchema.FieldNote);
        }

        protected override Entity ReadEntity(RecordReader reader)
        {
            Contact contact = this.NewContact();
            ContactRecord contactRecord = contact.ContactRecord;

            contactRecord.ID = reader.GetInt32(ContactSchema.FieldID);
            contactRecord.ContactType = (ContactType)reader.GetInt32(ContactSchema.FieldContactType);

            contactRecord.BilltoFirstName = reader.GetString(ContactSchema.FieldBillToFirstName);
            contactRecord.BilltoLastName = reader.GetString(ContactSchema.FieldBillToLastName);
            contactRecord.BilltoCompany = reader.GetString(ContactSchema.FieldBillToCompany);
            contactRecord.BilltoAddressLine1 = reader.GetString(ContactSchema.FieldBillToAddress1);
            contactRecord.BilltoAddressLine2 = reader.GetString(ContactSchema.FieldBillToAddress2);
            contactRecord.BilltoCity = reader.GetString(ContactSchema.FieldBillToCity);
            contactRecord.BilltoState = reader.GetString(ContactSchema.FieldBillToState);
            contactRecord.BilltoZip = reader.GetString(ContactSchema.FieldBillToZip);
            contactRecord.BilltoCountry = reader.GetString(ContactSchema.FieldBillToCountry);

            contactRecord.ShiptoFirstName = reader.GetString(ContactSchema.FieldShipToFirstName);
            contactRecord.ShiptoLastName = reader.GetString(ContactSchema.FieldShipToLastName);
            contactRecord.ShiptoCompany = reader.GetString(ContactSchema.FieldShipToCompany);
            contactRecord.ShiptoAddressLine1 = reader.GetString(ContactSchema.FieldShipToAddress1);
            contactRecord.ShiptoAddressLine2 = reader.GetString(ContactSchema.FieldShipToAddress2);
            contactRecord.ShiptoCity = reader.GetString(ContactSchema.FieldShipToCity);
            contactRecord.ShiptoState = reader.GetString(ContactSchema.FieldShipToState);
            contactRecord.ShiptoZip = reader.GetString(ContactSchema.FieldShipToZip);
            contactRecord.ShiptoCountry = reader.GetString(ContactSchema.FieldShipToCountry);

            contactRecord.PhoneNumber1 = reader.GetString(ContactSchema.FieldPhoneNumber1);
            contactRecord.PhoneNumber2 = reader.GetString(ContactSchema.FieldPhoneNumber2);
            contactRecord.ContactName = reader.GetString(ContactSchema.FieldContact);
            contactRecord.Fax = reader.GetString(ContactSchema.FieldFax);
            contactRecord.Email = reader.GetString(ContactSchema.FieldEmail);
            contactRecord.LastActivity = reader.GetString(ContactSchema.FieldLastActivity);
            contactRecord.Note = reader.GetString(ContactSchema.FieldNote);

            contactRecord.RepeatBilling = reader.GetBoolean(ContactSchema.FieldRepeatBilling);
            contactRecord.CustomerActiveStatus = reader.GetBoolean(ContactSchema.FieldCustomerActiveStatus);
            contactRecord.CustomerTax1 = reader.GetFloat(ContactSchema.FieldCustomerTax1);
            contactRecord.CustomerTax2 = reader.GetFloat(ContactSchema.FieldCustomerTax2);
            contactRecord.CustomerDiscount = reader.GetFloat(ContactSchema.FieldCustomerDiscount);
            contactRecord.CustomerCredit = reader.GetDecimal(ContactSchema.FieldCustomerCredit);
            contactRecord.CustomerCreditLimit = reader.GetDecimal(ContactSchema.FieldCustomerCreditLimit);
            contactRecord.CustomerCreditDate = reader.GetDateTime(ContactSchema.FieldCustomerCreditDate);

            contactRecord.VendorActiveStatus = reader.GetBoolean(ContactSchema.FieldVendorActiveStatus);
            contactRecord.VendorTax1 = reader.GetFloat(ContactSchema.FieldVendorTax1);
            contactRecord.VendorTax2 = reader.GetFloat(ContactSchema.FieldVendorTax2);
            contactRecord.VendorDiscount = reader.GetFloat(ContactSchema.FieldVendorDiscount);
            contactRecord.VendorCredit = reader.GetDecimal(ContactSchema.FieldVendorCredit);
            contactRecord.VendorCreditLimit = reader.GetDecimal(ContactSchema.FieldVendorCreditLimit);
            contactRecord.VendorCreditDate = reader.GetDateTime(ContactSchema.FieldVendorCreditDate);

            contactRecord.CreditCard.ID = reader.GetInt32Null(ContactSchema.FieldCreditCardID);
            return contact;
        }

        private Contact NewContact()
        {
            Contact contact = (Contact)Activator.CreateInstance(this.ContactClassType);
            return contact;
        }

        private void WhereContactKey(DbCommand command, ContactKey key)
        {
            CommandFactory.WhereAnd(command, ContactSchema.FieldBillToFirstName, key.FirstName);
            CommandFactory.WhereAnd(command, ContactSchema.FieldBillToLastName, key.LastName);
            CommandFactory.WhereAnd(command, ContactSchema.FieldBillToCompany, key.Company);
        }

        private ContactAccessor BrotherAccessor
        {
            get
            {
                if (this.ContactType == ContactType.Customer)
                    return this.Database.VendorAccessor;
                else
                    return this.Database.CustomerAccessor;
            }
        }

        private readonly Type ContactClassType;

        private readonly ContactType ContactType;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -