public int SaveAccounts(Entity.Sales.Accounts Model)
        {
            AccountsDbModel DbModel = new AccountsDbModel();

            Model.CopyPropertiesTo(DbModel);
            return(AccountDataAccess.SaveAccounts(DbModel));
        }
        protected void ddlLinkName_SelectedIndexChange(object sender, EventArgs e)
        {
            try
            {
                hdnOpenForm.Value = "true";
                if (ddlLinkName.SelectedIndex != 0)
                {
                    Business.Sales.Account Obj     = new Business.Sales.Account();
                    Entity.Sales.Accounts  Account = Obj.GetAccountById(Convert.ToInt32(ddlLinkName.SelectedValue), Convert.ToInt32(ActityType.Customer), Convert.ToInt32(ActityType.Account));
                    if (Account.Id != 0)
                    {
                        txtDescription.Text = Account.Description;
                        txtName.Text        = Account.Name;
                        txtOfficePhone.Text = Account.OfficePhone;
                        txtWebsite.Text     = Account.Website;
                    }
                }
            }
            catch (Exception ex)
            {
                ex.WriteException();

                Message.IsSuccess = false;
                Message.Text      = ex.Message;
                Message.Show      = true;
            }
        }
 private void Save()
 {
     if (AccountControlValidation())
     {
         Business.Sales.Account Obj   = new Business.Sales.Account();
         Entity.Sales.Accounts  Model = new Entity.Sales.Accounts
         {
             Id                   = AccountId,
             LeadSourceId         = ddlLeadSource.SelectedValue == "0" ? (int?)null : Convert.ToInt32(ddlLeadSource.SelectedValue),
             CustomerTypeId       = ddlCustomerType.SelectedValue == "0" ? (int?)null : Convert.ToInt32(ddlCustomerType.SelectedValue),
             CreatedBy            = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
             Description          = txtDescription.Text,
             Name                 = txtName.Text,
             Industry             = txtIndustry.Text,
             SourceName           = txtSourceName.Text,
             AccountScore         = txtAccountScore.Text == "" ? (decimal?)null : Convert.ToDecimal(txtAccountScore.Text),
             AnualRevenue         = txtAnnualRevenue.Text == "" ? (decimal?)null : Convert.ToDecimal(txtAnnualRevenue.Text),
             EmployeeStrength     = Convert.ToInt32(txtEmployeeStrength.Text),
             OfficePhone          = txtOfficePhone.Text,
             Website              = txtWebsite.Text,
             IsActive             = true,
             ActivityLinkId       = ActivityLinkId,
             ChildActivityTypeId  = Convert.ToInt32(ActityType.Account),
             SourceActivityTypeId = Convert.ToInt32(ActityType.Customer),
             SourceActivityId     = txtCustomerName.Text == "" ? (int?)null : Convert.ToInt32(GetCustomerIdByName(txtCustomerName.Text))
         };
         int rows = Obj.SaveAccounts(Model);
         if (rows > 0)
         {
             ClearControls();
             LoadAccountList();
             AccountId         = 0;
             Message.IsSuccess = true;
             Message.Text      = "Saved Successfully";
         }
         else
         {
             Message.IsSuccess = false;
             Message.Text      = "Unable to save data.";
         }
         Message.Show = true;
     }
 }
 private void GetAccountById()
 {
     Business.Sales.Account Obj     = new Business.Sales.Account();
     Entity.Sales.Accounts  Account = Obj.GetAccountById(AccountId, Convert.ToInt32(ActityType.Customer), Convert.ToInt32(ActityType.Account));
     if (Account.Id != 0)
     {
         ddlLeadSource.SelectedValue   = Account.LeadSourceId == null ? "0" : Account.LeadSourceId.ToString();
         ddlCustomerType.SelectedValue = Account.CustomerTypeId == null ? "0" : Account.CustomerTypeId.ToString();
         txtDescription.Text           = Account.Description;
         txtAccountScore.Text          = Account.AccountScore.ToString();
         txtAnnualRevenue.Text         = Account.AnualRevenue.ToString();
         txtEmployeeStrength.Text      = Account.EmployeeStrength.ToString();
         txtIndustry.Text     = Account.Industry;
         txtName.Text         = Account.Name;
         txtOfficePhone.Text  = Account.OfficePhone;
         txtSourceName.Text   = Account.SourceName;
         txtWebsite.Text      = Account.Website;
         txtCustomerName.Text = Account.CustomerName;
         ActivityLinkId       = Account.ActivityLinkId;
     }
 }
 public Entity.Sales.Accounts GetAccountById(int Id, int SourceTypeId, int ChildTypeId)
 {
     Entity.Sales.Accounts Account = new Entity.Sales.Accounts();
     AccountDataAccess.GetAccountById(Id, SourceTypeId, ChildTypeId).CopyPropertiesTo(Account);
     return(Account);
 }