Exemple #1
0
 /// <summary>
 /// this method will create applied permit affidavit costs
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public PermitCostsDetail InsertPermitCostsDetail(PermitCostsDetail model)
 {
     try
     {
         context.PermitCostsDetail.Add(model);
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         model = null;
     }
     return(model);
 }
Exemple #2
0
 /// <summary>
 /// this method will create applied permit affidavit costs
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public PermitCostsDetail InsertPermitCostsDetail(PermitCostsDetail model)
 {
     return(permitLogic.InsertPermitCostsDetail(model));
 }
Exemple #3
0
        async void SubmitApplication()
        {
            if ((bool)chkLegal.IsChecked)
            {
                Permit isExistingPermit;
                //Permit isExistingPermitByAddress;
                //try
                //{
                if ((bool)rdoAffidavit.IsChecked)
                {
                    var isExistingPermitByAffidavit = await _dataService.GetPermitByAffidavit(long.Parse(txtAffidavitSearch.Text));

                    isExistingPermit = isExistingPermitByAffidavit;
                }
                else
                {
                    var isExistingPermitByAddress = await _dataService.GetPermitByAffidavit(long.Parse(txtAffidavitSearch.Text));

                    isExistingPermit = isExistingPermitByAddress;
                }
                if (isExistingPermit == null)
                //if (isExistingPermit == null || (!(isExistingPermit.PermitStatus== Constants.PermitStatus_Submitted) || !(isExistingPermit.PermitStatus == Constants.PermitStatus_Accepted)))
                {
                    Permit        model    = new Permit();
                    AffidavitCart cartItem = new AffidavitCart();
                    //Insert applicant type
                    PermitApplicant applicant = new PermitApplicant();
                    if ((bool)rdoContractor.IsChecked)
                    {
                        model.ApplicantType     = "Contractor";
                        applicant.ApplicantType = "Contractor";
                    }
                    else if ((bool)rdoOwner.IsChecked)
                    {
                        model.ApplicantType     = "Owner";
                        applicant.ApplicantType = "Owner";
                    }
                    else if ((bool)rdoOther.IsChecked)
                    {
                        model.ApplicantType     = "Other";
                        applicant.ApplicantType = "Other";
                    }
                    applicant.Name        = txtContractorName.Text;
                    applicant.Address     = txtContractorAddress.Text;
                    applicant.Contact     = txtContractorContact.Text;
                    applicant.City        = txtContractorCity.Text;
                    applicant.Zip         = txtContractorZip.Text;
                    applicant.State       = txtContractorState.Text;
                    applicant.PhoneNumber = txtContractorPhone.Text;
                    //applicant.ContactPhoneNumber = txtContractorContactPhone.Text;
                    applicant.PermitID = 0;
                    applicant          = await _dataService.InsertPermitApplicant(applicant);

                    //Insert permit
                    if ((bool)rdoAffidavit.IsChecked)
                    {
                        model.AffidavitID        = long.Parse(txtAffidavitSearch.Text);
                        model.PropertyAddress    = txtPropertySearch.Text;
                        cartItem.AffidavitID     = txtAffidavitSearch.Text;
                        cartItem.PropertyAddress = txtPropertySearch.Text;
                    }
                    else
                    {
                        model.AffidavitID        = long.Parse(txtAffidavitSearch.Text);
                        model.PropertyAddress    = txtPropertySearch.Text;
                        cartItem.AffidavitID     = txtAffidavitSearch.Text;
                        cartItem.PropertyAddress = txtPropertySearch.Text;
                    }

                    if (!string.IsNullOrEmpty(txtContractorSearch.Text))
                    {
                        model.ContractorID = txtContractorSearch.Text.Split(',')[1].ToString();
                    }
                    else
                    {
                        model.ContractorID = string.Empty;
                    }
                    model.ApplicantID = applicant.ApplicantID;
                    //
                    //model.PermitNo = Aff
                    model.PermitIssued   = "No";
                    model.PermitExtended = "No";
                    model.BuilderBoardNo = txtCCBNumber.Text;
                    model.DateCancelled  = null;
                    model.CancelledBy    = string.Empty;
                    model.LastAction     = "Application Submitted";
                    model.DateExpired    = DateTime.Parse(txtExpirationDate.Text);
                    if ((bool)rdoContractor.IsChecked)
                    {
                        model.ApplicantType = "Contractor";
                    }
                    else if ((bool)rdoOwner.IsChecked)
                    {
                        model.ApplicantType = "Owner";
                        model.ContractorID  = "PO";
                    }
                    else if ((bool)rdoOther.IsChecked)
                    {
                        model.ApplicantType = "Other";
                        model.ContractorID  = "PO";
                    }
                    model.TotalFee       = decimal.Parse(txtFee.Text);
                    model.PermitStatus   = Constants.PermitStatus_Submitted;
                    model.SubmissionDate = DateTime.Now;

                    model = await _dataService.InsertPermit(model);

                    applicant.PermitID = model.PermitID;
                    var permitHistory = await _dataService.InsertPermitHistory(model.PermitID, "Submitted", "New permit applied.");

                    applicant = await _dataService.UpdatePermitApplicant(applicant);

                    int permitCount = int.Parse(lblAffidavitCount.Content.ToString());
                    lblAffidavitCount.Content = permitCount + 1;

                    cartItem.PermitID = model.PermitID.ToString();
                    cartItem.Remove   = "Remove";
                    cart.Add(cartItem);
                    affidavitGrid.ItemsSource = null;
                    affidavitGrid.ItemsSource = cart;
                    var affidavitFeeList = (List <sw_action_detail>)affidavitFee.ItemsSource;
                    foreach (var item in affidavitFeeList)
                    {
                        var Affidavit = await _dataService.GetAffidavitByNumber(item.aff_no.ToString());

                        PermitCostsDetail permitCosts = new PermitCostsDetail();
                        permitCosts.AffidavitID = item.aff_no;
                        permitCosts.Cost        = item.cost;
                        permitCosts.CostType    = item.action_type;
                        permitCosts.Rate        = item.rate;
                        permitCosts.Unit        = item.unit;
                        permitCosts.RepairItem  = item.action_type;

                        await _dataService.InsertPermitCostsDetail(permitCosts);
                    }
                    MessageBoxResult result = MessageBox.Show("Affidavit submitted successfully.  Do you want to apply for another permit?", "Confirmation", MessageBoxButton.YesNo);
                    if (result == MessageBoxResult.Yes)
                    {
                        ClearAffidavit();
                        chkLegal.IsChecked = false;
                    }
                    else
                    {
                        //if (!Convert.ToBoolean(ConfigurationManager.AppSettings["IsKiosk"].ToString()))
                        //{
                        //    MainWindow window = new MainWindow();
                        //    window.allPermitsOpen(_container);
                        //}
                        //else
                        //{
                        MainWindow window = new MainWindow();
                        window.newPermitOpen(_container);
                        //}
                    }
                }
                else
                {
                    MessageBox.Show("This affidavit has a permit pending for approval", "Permit Exist.");
                }
            }

            else
            {
                MessageBox.Show("Pls enter the Applicant, Name, Affidavit & agree to statement at the bottom");
            }
        }