public static Contractor Create(int id)
        {
            Contractor contractor = null;

            using (IDataReader reader = DBContractor.Get(id))
            {
                if(reader.Read())
                {
                    contractor = new Contractor(id);
                    contractor.Name = reader["Name"].ToString();
                    contractor.Phone = reader["Phone"].ToString();
                    contractor.Movile = reader["Movile"].ToString();
                    contractor.StatusCode = reader["Status"].ToString();
                }
            }

            if (contractor == null)
                return Contractor.Empty;

            using (IDataReader reader = DBContractor.GetAllSpecialties(id))
            {
                while (reader.Read())
                {
                    contractor.Specialties.Add(reader["SpecialtyId"].ToString());
                }
            }

            using (IDataReader reader = DBContractor.GetBankAccounts(id))
            {
                while (reader.Read())
                {
                    ContractorBankAccount bankAccount = new ContractorBankAccount(Convert.ToInt32(reader["ContractorAccountId"]));

                    bankAccount.AccountNumber = reader["Account"].ToString();
                    bankAccount.Bank = reader["Bank"].ToString();
                    contractor.BankAccounts.Add(bankAccount);
                }
            }

            return contractor;
        }
        private void LoadSettings()
        {
            int contractorId = Contractor.GetIdFromContract(_contractId);

            _payment = PaymentPaidWork.Create(_paymentId);
            _contractor = Contractor.Create(contractorId);
        }
        private void FillBankAccounts(Contractor contractor)
        {
            int count = contractor.BankAccounts.Count;

            if (count > 0)
            {
                BankAccountId1 = contractor.BankAccounts[0].Id;
                txtBank1.Text = contractor.BankAccounts[0].Bank;
                txtBankAccount1.Text = contractor.BankAccounts[0].AccountNumber;
            }

            if (count > 1)
            {
                BankAccountId2 = contractor.BankAccounts[1].Id;
                txtBank2.Text = contractor.BankAccounts[1].Bank;
                txtBankAccount2.Text = contractor.BankAccounts[1].AccountNumber;
            }

            if (count > 2)
            {
                BankAccountId3 = contractor.BankAccounts[2].Id;
                txtBank3.Text = contractor.BankAccounts[2].Bank;
                txtBankAccount3.Text = contractor.BankAccounts[2].AccountNumber;
            }
        }
        private void Save()
        {
            Contractor contractor = new Contractor(_contractorId);
            ContractorBankAccount bankAccount = null;

            contractor.Name = this.txtName.Text;
            contractor.Phone = this.txtPhone.Text;
            contractor.Movile = this.txtMovile.Text;
            contractor.StatusCode = this.ddlStatus.SelectedValue;

            foreach (ListItem item in this.lstSpecialties.Items)
            {
                if (item.Selected)
                {
                    contractor.Specialties.Add(item.Value);
                }
            }

            bankAccount = new ContractorBankAccount(BankAccountId1);
            bankAccount.Bank = txtBank1.Text;
            bankAccount.AccountNumber = txtBankAccount1.Text;
            contractor.BankAccounts.Add(bankAccount);

            bankAccount = new ContractorBankAccount(BankAccountId2);
            bankAccount.Bank = txtBank2.Text;
            bankAccount.AccountNumber = txtBankAccount2.Text;
            contractor.BankAccounts.Add(bankAccount);

            bankAccount = new ContractorBankAccount(BankAccountId3);
            bankAccount.Bank = txtBank3.Text;
            bankAccount.AccountNumber = txtBankAccount3.Text;
            contractor.BankAccounts.Add(bankAccount);

            contractor.Save();
        }
        private void LoadSettings()
        {
            JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
            PaymentSuccesDetail data;
            int contractorId = Contractor.GetIdFromContract(_contractId);

            _detail = new List<PaymentSuccesDetail>();

            foreach (string payableData in Request.Form.GetValues("payable-data"))
            {
                data = jsSerializer.Deserialize<PaymentSuccesDetail>(payableData);
                _detail.Add(data);
            }

            _payment = Payment.Create(_paymentId);
            _contractor = Contractor.Create(contractorId);
        }