示例#1
0
        public static AdjusterDeploymentAddress SaveDeploymentAddress(AdjusterDeploymentAddress objAdjusterDeploymentAddress)
        {
            DbContextHelper.DbContext.Add(objAdjusterDeploymentAddress);
            DbContextHelper.DbContext.SaveChanges();

            return objAdjusterDeploymentAddress;
        }
示例#2
0
        protected bool saveAdjuster()
        {
            AdjusterMaster adjuster = null;
            bool isSuccess = true;
            int yearsExperience = 0;
            int deploymentStateID = 0;
            int maxClaimNumner = 0;

            // 2013-08-07 tortega
            int clientID = Core.SessionHelper.getClientId();

            decimal fee = 0;
            int adjusterID = Convert.ToInt32(hdId.Value);

            string adjusterName = string.Format("{0} {1}", txtFirstName.Text, txtLastName.Text);

            using (TransactionScope scope = new TransactionScope()) {

                bool exists = AdjusterManager.IsExist(adjusterName, clientID);

                if (adjusterID == 0 && exists) {
                    lblMessage.Text = "Adjuster name already exists.";
                    lblMessage.Visible = true;
                    txtFirstName.Focus();
                    return false;
                }

                if (adjusterID > 0) {
                    // update adjuster
                    adjuster = AdjusterManager.GetAdjusterId(adjusterID);

                    adjuster.Status = cbxStatus.Checked;
                }
                else {
                    // mew adjuster
                    adjuster = new AdjusterMaster();

                    adjuster.Status = true;

                }

                adjuster.AdjusterName = adjusterName;
                adjuster.FirstName = txtFirstName.Text;
                adjuster.LastName = txtLastName.Text;
                adjuster.FederalTaxID = txtFedID.Text.Trim();
                adjuster.Address1 = txtAddress.Text.Trim();
                adjuster.Address2 = txtAddress2.Text.Trim();

                adjuster.CityName = txtCityName.Text.Trim();
                adjuster.ZipCode = txtZip.Text.Trim();
                adjuster.FederalTaxID = txtFedID.Text.Trim();

                adjuster.CompanyName = txtCompanyName.Text.Trim();
                adjuster.PhoneNumber = txtPhoneNumber.Text.Trim();//NEW OC 9/22/2014
                adjuster.CompanyPhone = txtCompanyPhone.Text.Trim();
                adjuster.FaxNumber = txtFaxNumber.Text.Trim();

                //decimal.TryParse(txtFeeContract.Text, out fee);
                adjuster.FeePerContract = fee;

                adjuster.isEmailNotification = cbxNotification.Checked;
                adjuster.isNotifyUserUploadDocument = cbxNotifyUserUploadDocument.Checked;
                adjuster.email = txtEmail.Text;

                adjuster.isW9 = cbxisW9.Checked;
                int.TryParse(txtYearExperience.Text, out yearsExperience);

                adjuster.YearsExperiece = yearsExperience;
                adjuster.GeographicalSeriveArea = txtServiceArea.Text;

                adjuster.Certifications = txtCertification.Text;

                // 2013-08-07 tortega
                if (clientID > 0)
                    adjuster.ClientId = clientID;

                adjuster.UseDeploymentAddress = cbxUseDeploymentAddress.Checked;

                if (ddlState.SelectedIndex > 0)
                    adjuster.StateID = Convert.ToInt32(ddlState.SelectedValue);
                else
                    adjuster.StateID = null;

                int.TryParse(txtMaxNumberClaims.Text, out maxClaimNumner);
                adjuster.MaxClaimNumber = maxClaimNumner;

                // 2014-05-02
                adjuster.XactNetAddress = txtXactNetAddress.Text;
                adjuster.HourlyRate = txtHourlyRate.ValueDecimal;
                adjuster.CommissionRate = txtCommissionRate.ValueDecimal;

                // 2014-05-04 tortega
                if (ddlSupervisor.SelectedIndex > 0)
                    adjuster.SupervisorID = Convert.ToInt32(ddlSupervisor.SelectedValue);

                int deploymentAddressId = 0;
                int.TryParse(ddlDeploymentAddress.SelectedValue, out deploymentAddressId);
                if (deploymentAddressId > 0)
                {
                    AdjusterDeploymentAddress objAdjusterDeploymentAddress = AdjusterManager.GetDeployementAddress(deploymentAddressId);
                    if (objAdjusterDeploymentAddress!=null)
                    {

                        adjuster.DeploymentAddress = objAdjusterDeploymentAddress.DeploymentAddress;
                        adjuster.DeploymentAddress2 = objAdjusterDeploymentAddress.DeploymentAddress2;
                        adjuster.DeploymentCity = objAdjusterDeploymentAddress.City;
                        if (objAdjusterDeploymentAddress.ZipCode!=null)
                        {
                            adjuster.DeploymentZipCode = Convert.ToString(objAdjusterDeploymentAddress.ZipCode);
                        }
                        adjuster.DeploymentStateID =objAdjusterDeploymentAddress.States;
                    }

                    //fill control
                    txtDeployAddress.Text = objAdjusterDeploymentAddress.DeploymentAddress;
                    txtDeployAddress2.Text = objAdjusterDeploymentAddress.DeploymentAddress2;
                    if (objAdjusterDeploymentAddress.States != null)
                    {
                        ddlDeployState.SelectedValue = Convert.ToString(objAdjusterDeploymentAddress.States);
                    }
                    else
                    {
                        ddlDeployState.SelectedValue = "0";
                    }
                    txtDeployCity.Text = objAdjusterDeploymentAddress.City;
                    if (objAdjusterDeploymentAddress.ZipCode!=null)
                       {
                            txtDeployZipCode.Text = Convert.ToString(objAdjusterDeploymentAddress.ZipCode);
                       }

                }
                else
                {
                    // deployment address
                    adjuster.DeploymentAddress = txtDeployAddress.Text;
                    adjuster.DeploymentAddress2 = txtDeployAddress2.Text;
                    adjuster.DeploymentCity = txtDeployCity.Text;
                    adjuster.DeploymentZipCode = txtDeployZipCode.Text;

                    int.TryParse(ddlDeployState.SelectedValue, out deploymentStateID);
                    if (deploymentStateID > 0)
                        adjuster.DeploymentStateID = deploymentStateID;

                    //code fro save deployment address
                    if (chkSaveAddress.Checked)
                    {
                        AdjusterDeploymentAddress objAdjusterDeploymentAddress2 = new AdjusterDeploymentAddress();
                        objAdjusterDeploymentAddress2.UserId = SessionHelper.getUserId();
                        objAdjusterDeploymentAddress2.DeploymentAddress = txtDeployAddress.Text;
                        objAdjusterDeploymentAddress2.DeploymentAddress2 = txtDeployAddress2.Text;
                        if (ddlDeployState.SelectedIndex > 0)
                            objAdjusterDeploymentAddress2.States = Convert.ToInt32(ddlDeployState.SelectedValue);
                        else
                            objAdjusterDeploymentAddress2.States = null;

                        objAdjusterDeploymentAddress2.City = txtDeployCity.Text;
                        objAdjusterDeploymentAddress2.IsActive = true;

                        if (!string.IsNullOrEmpty(txtDeployZipCode.Text))
                        {
                        objAdjusterDeploymentAddress2.ZipCode =Convert.ToInt32(txtDeployZipCode.Text);
                        }

                      AdjusterDeploymentAddress objAdjusterDeploymentAddress3 =  AdjusterManager.SaveDeploymentAddress(objAdjusterDeploymentAddress2);
                      adjuster.DeploymentAddressID = objAdjusterDeploymentAddress3.Id;
                    }

                }
                AdjusterManager.Save(adjuster);

                scope.Complete();

                isSuccess = true;

            }
            return isSuccess;
        }