Ejemplo n.º 1
0
        private string Submit(string id)
        {
            string message;
            try
            {
                if (CommonFunctions.CheckIfUserExists(id, id,out message, "GU"))
                {
                    using (var dataContext = new nChangerDb())
                    {
                        var user =
                            dataContext.Users.FirstOrDefault(
                                u => u.Email.ToLower().Equals(id) || u.UserId.ToLower().Equals(id));

                        if (user != null)
                        {
                            user.VerificationCode = Guid.NewGuid().ToString().ToLower();
                            dataContext.Users.AddOrUpdate(user);
                            dataContext.SaveChanges();
                            if (SendRecoveryMail(user))
                                message = "An email has been sent to you with instructions to reset your password.";
                            else
                                message = "There was a problem sending recovery email. Please try again in some time or contact administrator.";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }

            return message;
        }
Ejemplo n.º 2
0
        public bool Submit(out string returnMessage)
        {
            returnMessage = string.Empty;
            var success = true;
            try
            {
                var message = string.Empty;
                if (CommonFunctions.CheckIfUserExists(txtEmailId.Text, txtUserId.Text, out message,"GU"))
                {
                    returnMessage = message;
                    return false;
                }


                using (var dataContext = new nChangerDb())
                {
                    var dbEntry = new User
                    {
                        Id = Guid.NewGuid(),
                        UserTypeId="GU",
                        UserId = txtUserId.Text,
                        Email = txtEmailId.Text,
                        Password = txtPassword.Text,
                        FirstName = txtFirstName.Text,
                        MiddleName = txtMiddleName.Text,
                        LastName = txtLastName.Text,
                        Phone = txtPhone.Text,
                        City = txtCity.Text,
                        State = ddlState.SelectedIndex == -1 ? txtState.Text : ddlState.SelectedValue,
                        Zip = txtZipCode.Text,
                        Country = ddlCountry.SelectedValue,
                        Address = txtAddressLine1.Text,
                        Address2 = txtAddressLine2.Text,
                        IP = CommonFunctions.GetIpAddress(),
                        IsActive = false,
                        EmailVerified = false,
                        VerificationCode = Guid.NewGuid().ToString(),
                        RegistrationDate = DateTime.Now
                    };

                    dataContext.Users.Add(dbEntry);
                    dataContext.SaveChanges();
                    _queryId = dbEntry.UserId;
                    AddUserPackage(_queryId);
                    returnMessage = SendRegistrationMail(dbEntry) ? "SUCCESS" : "MAIL_ERROR";
                }

            }
            catch (DbEntityValidationException ex)
            {
                success = false;
                returnMessage = ex.EntityValidationErrors.SelectMany(eve => eve.ValidationErrors).Aggregate(returnMessage, (current, ve) => current + (ve.PropertyName + " Error Msg:" + ve.ErrorMessage));
            }

            return success;
        }
        protected void btnSubmit_OnClick(object sender, EventArgs e)
        {

            try
            {
                divMsg.InnerText = Submit();
                var sections = Sections;
                var page = Path.GetFileName(Request.PhysicalPath);
                var curret = Sections.FirstOrDefault(s => s.AspxPath.Contains(page));

                using (var dataContext = new nChangerDb())
                {
                    dataContext.Database.ExecuteSqlCommand("DELETE FROM UserFormDetail WHERE UserId='" + UserId +
                                                           "' AND PdfTemplateId='" + CurrentId + "'  AND FrmGuid='" +
                                                           curret.FrmGuid.ToString() + "'");

                    dataContext.UserFormDetails.AddOrUpdate(new UserFormDetail
                    {
                        Id = Guid.NewGuid(),
                        UserId = UserId,
                        AspxPath = curret.AspxPath,
                        TableName = curret.TableName,
                        PdfTemplateId = Guid.Parse(CurrentId),
                        FrmGuid = curret.FrmGuid,
                        Completed = "Y"
                    });

                    dataContext.SaveChanges();
                }
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }

            var nextPage = FormIndex + 1;
            var redirect = Sections.Where(s => s.DisplayOrder.Equals(nextPage)).FirstOrDefault().AspxPath;

            Response.Redirect(redirect);
        }
Ejemplo n.º 4
0
        public bool Submit()
        {
            var returnMessage = string.Empty;
            var success = true;
            var id = string.IsNullOrEmpty(hiddenProvinceId.Value) ? Guid.NewGuid() : Guid.Parse(hiddenProvinceId.Value);
            try
            {

                var message = string.Empty;

                using (var dataContext = new nChangerDb())
                {
                    var province = new Province()
                    {
                        Id = id,
                        ProvinceName = hidName.Value,
                        Description = hidDesc.Value,
                        IsActive = true,
                        EntryDate = DateTime.Now,
                        EntryIP = CommonFunctions.GetIpAddress(),
                        EntryId = UserId
                    };

                    dataContext.Provinces.AddOrUpdate(province);
                    dataContext.SaveChanges();
                }

            }
            catch (DbEntityValidationException ex)
            {
                success = false;
                returnMessage = ex.EntityValidationErrors.SelectMany(eve => eve.ValidationErrors).Aggregate(returnMessage, (current, ve) => current + (ve.PropertyName + " Error Msg:" + ve.ErrorMessage));
            }

           // lblMsg.Text = returnMessage;
            return success;
        }
Ejemplo n.º 5
0
        private void ActivateUser(string id)
        {
            try
            {
                using (var dataContext = new nChangerDb())
                {
                    var dbUser = dataContext.Users.FirstOrDefault(u => u.VerificationCode.ToLower().Equals(id));
                    if (dbUser != null)
                    {
                        dbUser.EmailVerified = true;
                        dbUser.IsActive = true;

                        dataContext.Users.AddOrUpdate(dbUser);
                        dataContext.SaveChanges();
                        ShowMessage(dbUser);
                    }
                }

            }
            catch (Exception ex)
            {

            }
        }
        public bool Submit()
        {
            var success = true;
            var id = string.IsNullOrEmpty(hiddenCategoryId.Value) ? Guid.NewGuid() : Guid.Parse(hiddenCategoryId.Value);
            try
            { 
                using (var dataContext = new nChangerDb())
                {
                    var category = new ProvinceCategory()
                    {
                        Id = id,
                        ProvinceId = string.IsNullOrEmpty(hiddenProvinceId.Value)? Guid.Parse(ddlProvinceAdd.SelectedValue):Guid.Parse(hiddenProvinceId.Value),
                        Category = hidCategoryName.Value,
                        Description = hidCategoryDesc.Value,
                        IsActive = true,
                        EntryDate = DateTime.Now,
                        EntryIP = CommonFunctions.GetIpAddress(),
                        EntryId = UserId
                    };

                    dataContext.ProvinceCategories.AddOrUpdate(category);
                    dataContext.SaveChanges();
                }

            }
            catch (DbEntityValidationException ex)
            {
                success = false;
            }
             
            return success;
        }
        private string Submit()
        {
            var id = Guid.Parse(RecordId);
            var returnMessage = string.Empty;
            try
            {
                using (var dataContext = new nChangerDb())
                {
                    var dbEntry = dataContext.CriminalOffenceInformations.Find(id);
                    
                    if (dbEntry != null)
                    {
                        dbEntry.UserId = UserId;
                        dbEntry.OutstandingCourtProceedings = rdLstOutstandingCourtProceedings.SelectedIndex == 0;
                        dbEntry.CourtFileNumber = txtCourtFileNumber.Text;
                        dbEntry.CourtName = txtCourtName.Text;
                        dbEntry.CourtAddress = txtCourtAddress.Text;
                        dbEntry.DescribeProceedings = txtDescribeProceedings.Text;
                        dbEntry.OutstandingEnforcementOrders = rdLstOutstandingEnforcementOrders.SelectedIndex == 0;
                        dbEntry.DetailsOfOutstandingEnforcementOrders = txtDetailsOfOutstandingEnforcementOrders.Text;
                        dbEntry.EverConvictedOfCriminalOffence = rdLstEverConvictedOfCriminalOffence.SelectedIndex == 0;
                        dbEntry.DetailsOfCriminalOffence = txtDetailsOfCriminalOffence.Text;
                        dbEntry.FoundGuiltyDischarged = rdLstFoundGuiltyDischarged.SelectedIndex == 0;
                        dbEntry.FoundGuiltyDetailsOfOffence = txtFoundGuiltyDetailsOfOffence.Text;
                        dbEntry.AdultSentenceImposed = rdLstAdultSentenceImposed.SelectedIndex == 0;
                        dbEntry.DescribeAdultSentence = txtDescribeAdultSentence.Text;
                        dbEntry.PendingCharges = rdLstPendingCharges.SelectedIndex == 0;
                        dbEntry.PendingChargesCourtNumber = txtPendingChargesCourtNumber.Text;
                        dbEntry.PendingChargesCourtName = txtPendingChargesCourtName.Text;
                        dbEntry.PendingChargesCourtAddress = txtPendingChargesCourtAddress.Text;
                        dbEntry.PendingChargesDescribe = txtPendingChargesDescribe.Text;
                        dbEntry.EntryDate = DateTime.Today;
                        dbEntry.EntryIP = CommonFunctions.GetIpAddress();
                        dbEntry.IsActive = true;
                        dbEntry.EntryId = UserId;
                    }
                    else
                    {
                        var entry = new CriminalOffenceInformation
                        {
                            Id = id,
                            PdfFormTemplateId = Guid.Parse(CurrentId),
                            UserId = UserId,
                            OutstandingCourtProceedings = rdLstOutstandingCourtProceedings.SelectedIndex == 0,
                            CourtFileNumber = txtCourtFileNumber.Text,
                            CourtName = txtCourtName.Text,
                            CourtAddress = txtCourtAddress.Text,
                            DescribeProceedings = txtDescribeProceedings.Text,
                            OutstandingEnforcementOrders = rdLstOutstandingEnforcementOrders.SelectedIndex == 0,
                            DetailsOfOutstandingEnforcementOrders = txtDetailsOfOutstandingEnforcementOrders.Text,
                            EverConvictedOfCriminalOffence = rdLstEverConvictedOfCriminalOffence.SelectedIndex == 0,
                            DetailsOfCriminalOffence = txtDetailsOfCriminalOffence.Text,
                            FoundGuiltyDischarged = rdLstFoundGuiltyDischarged.SelectedIndex == 0,
                            FoundGuiltyDetailsOfOffence = txtFoundGuiltyDetailsOfOffence.Text,
                            AdultSentenceImposed = rdLstAdultSentenceImposed.SelectedIndex == 0,
                            DescribeAdultSentence = txtDescribeAdultSentence.Text,
                            PendingCharges = rdLstPendingCharges.SelectedIndex == 0,
                            PendingChargesCourtNumber = txtPendingChargesCourtNumber.Text,
                            PendingChargesCourtName = txtPendingChargesCourtName.Text,
                            PendingChargesCourtAddress = txtPendingChargesCourtAddress.Text,
                            PendingChargesDescribe = txtPendingChargesDescribe.Text,
                            EntryDate = DateTime.Today,
                            EntryIP = CommonFunctions.GetIpAddress(),
                            IsActive = true,
                            EntryId = UserId,
                        };

                        dataContext.CriminalOffenceInformations.Add(entry);
                    }

                    dataContext.SaveChanges();

                    returnMessage = "Data submitted successfully!";
                     
                }
            }
            catch (DbEntityValidationException ex)
            {
                returnMessage =
                    ex.EntityValidationErrors.SelectMany(eve => eve.ValidationErrors)
                        .Aggregate(returnMessage,
                            (current, ve) => current + (ve.PropertyName + " Error Msg:" + ve.ErrorMessage));
            }

            return returnMessage;
        }
Ejemplo n.º 8
0
        public bool Submit()
        {
            var success = true;
            var id = string.IsNullOrEmpty(hidQuestionId.Value) ? Guid.NewGuid() : Guid.Parse(hidQuestionId.Value);
            try
            {
                using (var dataContext = new nChangerDb())
                {
                    var question = new DefineQuestion()
                    {
                        Id = id,
                        ProvinceCategoryId = string.IsNullOrEmpty(hidProvinceCategoryId.Value)?Guid.Parse(ddlCategoryAdd.SelectedValue):Guid.Parse(hidProvinceCategoryId.Value),
                        Question = hidQuestion.Value,
                        QuestionType = hidQuestionType.Value,
                        DataSource = string.IsNullOrEmpty(hidPreset.Value)?null:hidPreset.Value,
                        IsActive =true,
                        EntryDate = DateTime.Now,
                        EntryIP = CommonFunctions.GetIpAddress(),
                        EntryId = UserId,

                    };

                    dataContext.DefineQuestions.AddOrUpdate(question);

                    #region Options...

                    dataContext.Database.ExecuteSqlCommand("DELETE FROM QuestionOptions WHERE DefineQuestionsId='" + id + "'");

                    if (!string.IsNullOrEmpty(hidOptions.Value))
                    {
                        if (!hidOptions.Value.Contains(","))
                        {
                            var option = new QuestionOption
                            {
                                Id = Guid.NewGuid(),
                                DefineQuestionsId = id,
                                OptionLabel = hidOptions.Value,
                                EntryDate = DateTime.Now,
                                EntryIP = CommonFunctions.GetIpAddress(),
                                EntryId = UserId,
                                IsActive = true
                            };

                            dataContext.QuestionOptions.AddOrUpdate(option);

                        }
                        else
                        {
                            var optionsArray = hidOptions.Value.EndsWith(",")? hidOptions.Value.Substring(0, hidOptions.Value.Length - 1).Split(','): hidOptions.Value.Split(',');

                            foreach (var option in optionsArray.Select(item => new QuestionOption
                            {
                                Id = Guid.NewGuid(),
                                DefineQuestionsId = id,
                                OptionLabel = item,
                                EntryDate = DateTime.Now,
                                EntryIP = CommonFunctions.GetIpAddress(),
                                EntryId = UserId,
                                IsActive = true
                            }))
                            {
                                dataContext.QuestionOptions.AddOrUpdate(option);
                            }
                        }
                    }

                    #endregion Package Features...

                    dataContext.SaveChanges();
                    lblMsg.Text = "Question " + (string.IsNullOrEmpty(hidQuestionId.Value) ? "added" : "updated") + " successfully.";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "showAlert()", true);
                }
            }
            catch (DbEntityValidationException ex)
            {
                lblMsg.Text = ex.Message;
                success = false;
            }

            return success;
        }
        private string Submit()
        {
            var id = Guid.Parse(RecordId);
            var returnMessage = string.Empty;
            try
            {
                using (var dataContext = new nChangerDb())
                {
                    var dbEntry = dataContext.FinancialInformations.Find(id);
                     
                    if (dbEntry != null)
                    {
                        dbEntry.UserId = UserId;
                        dbEntry.CourtOrTribunalOrder = rdLstCourtOrTribunalOrder.SelectedIndex == 0;
                        dbEntry.CourtFileNumber = txtCourtFileNumber.Text;
                        dbEntry.NameOfCourt = txtNameOfCourt.Text;
                        dbEntry.DateOfCourtOrderDay = string.IsNullOrEmpty(txtDateCourtOrder.Text)
                            ? 0
                            : DateTime.ParseExact(txtDateCourtOrder.Text, "MM/dd/yyyy", null).Day;
                        dbEntry.DateOfCourtOrderMonth = string.IsNullOrEmpty(txtDateCourtOrder.Text)
                            ? 0
                            : DateTime.ParseExact(txtDateCourtOrder.Text, "MM/dd/yyyy", null).Month;
                        dbEntry.DateOfCourtOrderYear = string.IsNullOrEmpty(txtDateCourtOrder.Text)
                            ? 0
                            : DateTime.ParseExact(txtDateCourtOrder.Text, "MM/dd/yyyy", null).Year;
                        dbEntry.NameOfPersonWhoSuedYou = txtNameOfPersonWhoSuedYou.Text;
                        dbEntry.AddressCourtTribunal = txtAddressCourtTribunal.Text;
                        dbEntry.SheriffDirected = rdLstSheriffDirected.SelectedIndex == 0;
                        dbEntry.WritNumber = txtWritNumber.Text;
                        dbEntry.NameOfSherrif = txtNameOfSherrif.Text;
                        dbEntry.AddressOfSheriff = txtAddressOfSheriff.Text;
                        dbEntry.LiensOrSecurityInterests = rdLstLiensOrSecurityInterests.SelectedIndex == 0;
                        dbEntry.LiensOrSecurityInterestsNameOfPerson = txtLiensOrSecurityInterestsNameOfPerson.Text;
                        dbEntry.AmountOfMoneyOwed = txtAmountOfMoneyOwed.Text;
                        dbEntry.RegitrationNumber = txtRegitrationNumber.Text;
                        dbEntry.FinancialStatementsRegistered = rdLstFinancialStatementsRegistered.SelectedIndex == 0;
                        dbEntry.FinancialStatementsRegitrationNumber = txtFinancialStatementsRegitrationNumber.Text;
                        dbEntry.UndischargedBankrupt = rdLstUndischargedBankrupt.SelectedIndex == 0;
                        dbEntry.DetailsOfBankruptcy = txtDetailsOfBankruptcy.Text;
                        dbEntry.EntryDate = DateTime.Today;
                        dbEntry.EntryIP = CommonFunctions.GetIpAddress();
                        dbEntry.IsActive = true;
                        dbEntry.EntryId = UserId;
                    }
                    else
                    {
                        var entry = new FinancialInformation
                        {
                            Id = id,
                            PdfFormTemplateId = Guid.Parse(CurrentId),
                            UserId = UserId,
                            CourtOrTribunalOrder = rdLstCourtOrTribunalOrder.SelectedIndex == 0,
                            CourtFileNumber = txtCourtFileNumber.Text,
                            NameOfCourt = txtNameOfCourt.Text,
                            DateOfCourtOrderDay =
                                string.IsNullOrEmpty(txtDateCourtOrder.Text)
                                    ? 0
                                    : DateTime.ParseExact(txtDateCourtOrder.Text, "MM/dd/yyyy", null).Day,
                            DateOfCourtOrderMonth =
                                string.IsNullOrEmpty(txtDateCourtOrder.Text)
                                    ? 0
                                    : DateTime.ParseExact(txtDateCourtOrder.Text, "MM/dd/yyyy", null).Month,
                            DateOfCourtOrderYear =
                                string.IsNullOrEmpty(txtDateCourtOrder.Text)
                                    ? 0
                                    : DateTime.ParseExact(txtDateCourtOrder.Text, "MM/dd/yyyy", null).Year,
                            NameOfPersonWhoSuedYou = txtNameOfPersonWhoSuedYou.Text,
                            AddressCourtTribunal = txtAddressCourtTribunal.Text,
                            SheriffDirected = rdLstSheriffDirected.SelectedIndex == 0,
                            WritNumber = txtWritNumber.Text,
                            NameOfSherrif = txtNameOfSherrif.Text,
                            AddressOfSheriff = txtAddressOfSheriff.Text,
                            LiensOrSecurityInterests = rdLstLiensOrSecurityInterests.SelectedIndex == 0,
                            LiensOrSecurityInterestsNameOfPerson = txtLiensOrSecurityInterestsNameOfPerson.Text,
                            AmountOfMoneyOwed = txtAmountOfMoneyOwed.Text,
                            RegitrationNumber = txtRegitrationNumber.Text,
                            FinancialStatementsRegistered = rdLstFinancialStatementsRegistered.SelectedIndex == 0,
                            FinancialStatementsRegitrationNumber = txtFinancialStatementsRegitrationNumber.Text,
                            UndischargedBankrupt = rdLstUndischargedBankrupt.SelectedIndex == 0,
                            DetailsOfBankruptcy = txtDetailsOfBankruptcy.Text,
                            EntryDate = DateTime.Today,
                            EntryIP = CommonFunctions.GetIpAddress(),
                            IsActive = true,
                            EntryId = UserId,
                        };

                        dataContext.FinancialInformations.Add(entry);
                    }

                    dataContext.SaveChanges();

                    returnMessage = "Data submitted successfully!";
                     
                }
            }
            catch (DbEntityValidationException ex)
            {
                returnMessage =
                    ex.EntityValidationErrors.SelectMany(eve => eve.ValidationErrors)
                        .Aggregate(returnMessage,
                            (current, ve) => current + (ve.PropertyName + " Error Msg:" + ve.ErrorMessage));
            }

            return returnMessage;
        }
Ejemplo n.º 10
0
        private bool AddUserPackage(string userId)
        {
            var success = true;
            try
            {
                using (var dataContext = new nChangerDb())
                {
                    dataContext.UserPackages.Add(new UserPackage
                    {
                        Id=Guid.NewGuid(),
                        PackageId = Guid.Parse(Request.QueryString["pid"]),
                        UserId=userId,
                    });

                    dataContext.SaveChanges();
                }
            }
            catch (Exception exception)
            {
                var msg = exception.Message;
                success = false;
            }

            return success;
        }
Ejemplo n.º 11
0
        public bool Submit()
        {
            var success = true;
            var id = string.IsNullOrEmpty(hidPackageId.Value) ? Guid.NewGuid() : Guid.Parse(hidPackageId.Value);
            try
            {
                using (var dataContext = new nChangerDb())
                {
                    var package = new Package()
                    {
                        Id = id,
                        PackageName = hidPackageName.Value,
                        Price = Convert.ToDecimal(hidPrice.Value),
                        IsActive = !string.IsNullOrEmpty(hidActive.Value) && Convert.ToBoolean(hidActive.Value),
                        EntryDate = DateTime.Now,
                        EntryIP = CommonFunctions.GetIpAddress(),
                        EntryId = UserId,

                    };

                    dataContext.Packages.AddOrUpdate(package);

                    #region Package Features...
                     
                    dataContext.Database.ExecuteSqlCommand("DELETE FROM PackageFeature WHERE PackageId='"+id+"'");

                    if (!string.IsNullOrEmpty(hidFeatures.Value))
                    {
                        var featureArray = hidFeatures.Value.Substring(0, hidFeatures.Value.Length - 1).Split(',');

                        foreach (var feature in featureArray.Select(item => new PackageFeature
                        {
                            Id = Guid.NewGuid(),
                            PackageId = id,
                            FeatureId = Guid.Parse(chkFeatures.Items.FindByText(item).Value),
                            FeatureName = item,
                            EntryDate = DateTime.Now,
                            EntryIP = CommonFunctions.GetIpAddress(),
                            EntryId = UserId,
                            IsActive = true
                        }))
                        {
                            dataContext.PackageFeatures.AddOrUpdate(feature);
                        }
                    }

                    #endregion Package Features...
                     
                    dataContext.SaveChanges();
                    lblMsg.Text = "Package \"" + package.PackageName + "\" " + (string.IsNullOrEmpty(hidPackageId.Value) ?  "added" : "updated") + " successfully.";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "showAlert()", true);
                }
            }
            catch (DbEntityValidationException ex)
            {
                success = false;
            }

            return success;
        }
Ejemplo n.º 12
0
        private void UploadPdf(string file)
        {
            var id = Request.UrlReferrer.Query.Substring(4);
            try
            {
                using (var dataContext = new nChangerDb())
                {
                    if (Request.UrlReferrer != null)
                        dataContext.PdfFormTemplates.Add(new PdfFormTemplate
                        {

                            Id = Guid.NewGuid(),
                            ProvinceCategoryId = Guid.Parse(Request.UrlReferrer.Query.Substring(4)),
                            PdfFileName = file,
                            TemplateName = file,
                            EntryIP = CommonFunctions.GetIpAddress(),
                            EntryId = UserId,
                            EntryDate = DateTime.Now,
                            IsActive = false,
                        });

                    dataContext.SaveChanges();
                }
            }
            catch (DbEntityValidationException ex)
            {
                foreach (var eve in ex.EntityValidationErrors)
                {
                    lblMsg.Text += eve.Entry.Entity.GetType().Name + "<br/>" + eve.Entry.State;
                    foreach (var ve in eve.ValidationErrors)
                    {
                        lblMsg.Text += ve.PropertyName + "<br/>" + ve.ErrorMessage;
                    }
                }
            }

        }
Ejemplo n.º 13
0
        private void UpdateGeneratedPdf(FileInfo fileInfo)
        {
            var id = Guid.Parse(RecordId);
            var pdfFormTemplateid = Guid.Parse(CurrentId);
            using (var dataContext=new nChangerDb())
            {
                var dbEntry = dataContext.GeneratedPdfs.Find(id);
                if (dbEntry != null)
                {
                    dataContext.GeneratedPdfs.Remove(dbEntry);
                    dataContext.SaveChanges();
                }

                dataContext.GeneratedPdfs.AddOrUpdate(new GeneratedPdf
                {
                    Id=id,
                    PdfFormTemplateId = pdfFormTemplateid,
                    UserId = UserId,
                    CompletedPdf ="../Output/"+Path.GetFileName(fileInfo.Name),
                    EntryDate = DateTime.Now,
                    EntryIP = CommonFunctions.GetIpAddress(),
                    EntryId= UserId,
                    IsActive=true
                });

                dataContext.SaveChanges();
            }
        }
Ejemplo n.º 14
0
        protected void btnSubmit_OnClick(object sender, EventArgs e)
        {
            RemoveExisting();

            var id = Guid.Parse(RecordId);

            foreach (HtmlTableRow row in tblFields.Rows)
            {
                {
                    foreach (HtmlTableCell cell in row.Cells)
                    {
                        foreach (var ctl in cell.Controls)
                        {
                            if (ctl.GetType() == typeof (TextBox))
                            {
                                var txt = (TextBox) ctl;

                                using (var dataContext = new nChangerDb())
                                {
                                    dataContext.GeneralQuestionUserResponses.AddOrUpdate(new GeneralQuestionUserResponse
                                    {
                                        Id = Guid.NewGuid(),
                                        RecordId = id,
                                        Question = txt.Attributes["placeholder"].ToString(),
                                        UserAnswer = txt.Text,
                                        PdfFormTemplateId = Guid.Parse(CurrentId),
                                        UserId = UserId,
                                        DefineQuestionId = Guid.Parse(Convert.ToString(txt.Attributes["DB_ID"])),
                                        EntryDate = DateTime.Now,
                                        EntryIP = CommonFunctions.GetIpAddress(),
                                        EntryId = UserId,
                                        IsActive = true
                                    });

                                    dataContext.SaveChanges();
                                }

                            }
                            else if (ctl.GetType() == typeof (RadioButtonList))
                            {
                                var rdList = (RadioButtonList) ctl;
                                using (var dataContext = new nChangerDb())
                                {
                                    dataContext.GeneralQuestionUserResponses.AddOrUpdate(new GeneralQuestionUserResponse
                                    {
                                        Id = Guid.NewGuid(),
                                        RecordId = id,
                                        Question = rdList.Attributes["Question"].ToString(),
                                        UserAnswer =
                                            rdList.SelectedIndex != -1 ? rdList.SelectedItem.Text : string.Empty,
                                        PdfFormTemplateId = Guid.Parse(CurrentId),
                                        UserId = UserId,
                                        DefineQuestionId = Guid.Parse(Convert.ToString(rdList.Attributes["DB_ID"])),
                                        EntryDate = DateTime.Now,
                                        EntryIP = CommonFunctions.GetIpAddress(),
                                        EntryId = UserId,
                                        IsActive = true
                                    });

                                    dataContext.SaveChanges();
                                }
                            }
                            else if (ctl.GetType() == typeof (DropDownList))
                            {
                                var ddl = (DropDownList) ctl;
                                using (var dataContext = new nChangerDb())
                                {
                                    dataContext.GeneralQuestionUserResponses.AddOrUpdate(new GeneralQuestionUserResponse
                                    {
                                        Id = Guid.NewGuid(),
                                        RecordId = id,
                                        Question = ddl.Attributes["Question"].ToString(),
                                        UserAnswer = ddl.SelectedIndex != -1 ? ddl.SelectedItem.Text : string.Empty,
                                        PdfFormTemplateId = Guid.Parse(CurrentId),
                                        UserId = UserId,
                                        DefineQuestionId = Guid.Parse(Convert.ToString(ddl.Attributes["DB_ID"])),
                                        EntryDate = DateTime.Now,
                                        EntryIP = CommonFunctions.GetIpAddress(),
                                        EntryId = UserId,
                                        IsActive = true
                                    });

                                    dataContext.SaveChanges();
                                }
                            }
                        }
                    }
                }
            }

            var redirect = Sections.Where(s => s.DisplayOrder.Equals(1)).FirstOrDefault().AspxPath;
            Response.Redirect(redirect);
        }
        private string Submit()
        {

            var id = Guid.Parse(RecordId);
            var returnMessage = string.Empty;
            try
            {
                using (var dataContext = new nChangerDb())
                {
                    var dbEntry = dataContext.ParentInformations.Find(id);
                     
                    if (dbEntry != null)
                    {
                         dbEntry.FatherFirstName = txtFatherFirstName.Text;
                         dbEntry.FatherMiddleName = txtFatherMiddleName.Text;
                         dbEntry.FatherLastName = txtFatherLastName.Text;
                         dbEntry.FatherOtherLastName = txtFatherLastNameOther.Text;
                         dbEntry.MotherFirstName = txtMotherFirstName.Text;
                         dbEntry.MotherMiddleName = txtMotherMiddleName.Text;
                         dbEntry.MotherLastNameWhenBorn = txtMotherLastNameBorn.Text;
                         dbEntry.MotherLastNamePresent = txtMotherLastNamePresent.Text;
                         dbEntry.MotherLastNameOther = txtMotherLastNameOther.Text;
                         dbEntry.EntryDate = DateTime.Today;
                         dbEntry.EntryIP = CommonFunctions.GetIpAddress();
                         dbEntry.IsActive = true;
                         dbEntry.EntryId = UserId;

                         dataContext.Entry(dbEntry).State = EntityState.Modified;
                    }
                    else
                    {
                        var entry = new ParentInformation()
                        {
                            Id = id,
                            PdfFormTemplateId = Guid.Parse(CurrentId),
                            UserId = UserId,
                            FatherFirstName = txtFatherFirstName.Text,
                            FatherMiddleName = txtFatherMiddleName.Text,
                            FatherLastName = txtFatherLastName.Text,
                            FatherOtherLastName = txtFatherLastNameOther.Text,
                            MotherFirstName = txtMotherFirstName.Text,
                            MotherMiddleName = txtMotherMiddleName.Text,
                            MotherLastNameWhenBorn = txtMotherLastNameBorn.Text,
                            MotherLastNamePresent = txtMotherLastNamePresent.Text,
                            MotherLastNameOther = txtMotherLastNameOther.Text,
                            EntryDate = DateTime.Today,
                            EntryIP = CommonFunctions.GetIpAddress(),
                            IsActive = true,
                            EntryId = UserId
                        };

                         dataContext.ParentInformations.Add(entry);
 
                    }
                     
                    dataContext.SaveChanges();

                    returnMessage = "Data submitted successfully!";
                    
                }
            }
            catch (DbEntityValidationException ex)
            {
                returnMessage = ex.EntityValidationErrors.SelectMany(eve => eve.ValidationErrors).Aggregate(returnMessage, (current, ve) => current + (ve.PropertyName + " Error Msg:" + ve.ErrorMessage));
            }

            return returnMessage;
        }
        protected void gvProvinceCategory_OnRowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            var id = Guid.Parse(Convert.ToString(gvProvinceCategory.DataKeys[e.RowIndex].Values[0]));

            try
            {
                using (var dataContext = new nChangerDb())
                {
                    var dbEntry = dataContext.ProvinceCategories.Find(id);
                    dataContext.ProvinceCategories.Remove(dbEntry);
                    dataContext.SaveChanges();
                    lblMsg.Text = "Category " + dbEntry.Category + " deleted successfully.";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "showAlert()", true);
                    if (Request.QueryString["id"] != null)
                        BindCateory(Guid.Parse(Request.QueryString["id"]));
                    else
                        BindCateory();
                }
            }
            catch (Exception exception)
            {
                lblMsg.Text = exception.Message;
            }
        }
Ejemplo n.º 17
0
        protected void gvPackage_OnRowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            var id = Guid.Parse(Convert.ToString(gvPackage.DataKeys[e.RowIndex].Values[0]));

            try
            {
                using (var dataContext = new nChangerDb())
                {
                    var dbEntry = dataContext.Packages.Find(id);
                    dataContext.Packages.Remove(dbEntry);
                    dataContext.SaveChanges();
                    BindPackages();
                    lblMsg.Text = "Package \"" + dbEntry.PackageName + "\" deleted successfully.";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "showAlert()", true);
                }
            }
            catch (Exception exception)
            {
                lblMsg.Text = exception.Message;
            }
        }
        private string Submit()
        {

            var id = Guid.Parse(RecordId);
            var returnMessage = string.Empty;
            try
            {
                using (var dataContext=new nChangerDb())
                {
                    var dbEntry = dataContext.PersonalInformations.Find(id);

                    if (dbEntry != null)
                    {
                        dbEntry.PresentFirstName = txtPresentFirstName.Text;
                        dbEntry.PresentMiddleName = txtPresentMiddleName.Text;
                        dbEntry.PresentLastName = txtPresentLastName.Text;
                        dbEntry.Sex =rdListSex.SelectedIndex==-1?string.Empty: rdListSex.SelectedItem.Value;
                        dbEntry.MailAddStreetNo = txtMailAddStreetNo.Text;
                        dbEntry.MailAddPOBox = txtMailAddPOBox.Text;
                        dbEntry.MailAddAptSuitNo = txtMailAddAptSuitNo.Text;
                        dbEntry.MailAddBuzzerNo = txtMailAddBuzzerNo.Text;
                        dbEntry.MailAddCityTownVillage = txtMailAddCityTownVillage.Text;
                        dbEntry.MailAddProvience = txtMailAddProvience.Text;
                        dbEntry.MailAddPostalCode = txtMailAddPostalCode.Text;
                        dbEntry.MailAddHomePhoneCode = txtMailAddHomePhoneCode.Text;
                        dbEntry.MailAddHomePhoneNo = txtMailAddHomePhoneNo.Text;
                        dbEntry.MailAddWorkPhoneCode = txtMailAddWorkPhoneCode.Text;
                        dbEntry.MailAddWorkPhoneNo = txtMailAddWorkPhoneNo.Text;
                        dbEntry.LivedInOntarioYears = string.IsNullOrEmpty(txtLivedInOntarioYears.Text)?0:Convert.ToInt32(txtLivedInOntarioYears.Text);
                        dbEntry.LivedInOntarioMonths = string.IsNullOrEmpty(txtLivedInOntarioMonths.Text) ? 0 : Convert.ToInt32(txtLivedInOntarioMonths.Text);
                        dbEntry.LivedInOntarioPast12Months = rdListLivedInOntarioPast12Months.SelectedIndex==-1?string.Empty : rdListLivedInOntarioPast12Months.SelectedValue;
                        dbEntry.DOBYear = string.IsNullOrEmpty(txtDOB.Text) ? 0 : DateTime.ParseExact(txtDOB.Text, "MM/dd/yyyy", null).Year;
                        dbEntry.DOBMonth = string.IsNullOrEmpty(txtDOB.Text) ? 0 : DateTime.ParseExact(txtDOB.Text, "MM/dd/yyyy", null).Month;
                        dbEntry.DOBDay = string.IsNullOrEmpty(txtDOB.Text) ? 0 : DateTime.ParseExact(txtDOB.Text, "MM/dd/yyyy", null).Day;
                        dbEntry.BirthCityTownVillage = txtBirthCityTownVillage.Text;
                        dbEntry.BirthProvinceOrState = txtBirthProvinceOrState.Text;
                        dbEntry.BirthCountry = txtBirthCountry.Text;
                        dbEntry.NewFirstName = txtNewFirstName.Text;
                        dbEntry.NewMiddleName = txtNewMiddleName.Text;
                        dbEntry.NewLastName = txtNewLastName.Text;
                        dbEntry.Married = rdListMarried.SelectedValue;
                        dbEntry.PartnerFisrtName = txtPartnerFisrtName.Text;
                        dbEntry.PartnerMiddleName = txtPartnerMiddleName.Text;
                        dbEntry.PartnerLastName = txtPartnerLastName.Text;
                        dbEntry.DateMarriedMonth = string.IsNullOrEmpty(txtDateMarried.Text) ? 0 : DateTime.ParseExact(txtDateMarried.Text, "MM/dd/yyyy",null).Month;
                        dbEntry.DateMarriedDay = string.IsNullOrEmpty(txtDateMarried.Text) ? 0 : DateTime.ParseExact(txtDateMarried.Text, "MM/dd/yyyy",null).Day;
                        dbEntry.DateMarriedYear = string.IsNullOrEmpty(txtDateMarried.Text) ? 0 : DateTime.ParseExact(txtDateMarried.Text, "MM/dd/yyyy", null).Year;
                        dbEntry.CityTownMarried = txtCityTownMarried.Text;
                        dbEntry.StateOrProvinceMarried = txtStateOrProvinceMarried.Text;
                        dbEntry.CountryMarried =ddlCountryMarried.SelectedIndex==-1?string.Empty:ddlCountryMarried.SelectedValue;
                        dbEntry.JDeclarationSigned = rdListJDeclarationSigned.SelectedIndex == -1 ? string.Empty : rdListJDeclarationSigned.SelectedValue;
                        dbEntry.JDeclarationPersonFirstName = txtJDeclarationPersonFirstName.Text;
                        dbEntry.JDeclarationPersonMiddleName = txtJDeclarationPersonMiddleName.Text;
                        dbEntry.JDeclarationPersonLastName = txtJDeclarationPersonLastName.Text;
                        dbEntry.SentRegistrarMonth = string.IsNullOrEmpty(txtSentRegistrarDate.Text) ? 0 : DateTime.ParseExact(txtSentRegistrarDate.Text, "MM/dd/yyyy", null).Month;
                        dbEntry.SentRegistrarDay = string.IsNullOrEmpty(txtSentRegistrarDate.Text) ? 0 : Convert.ToDateTime(txtSentRegistrarDate.Text).Day;
                        dbEntry.SentRegistrarYear = string.IsNullOrEmpty(txtSentRegistrarDate.Text) ? 0 : Convert.ToDateTime(txtSentRegistrarDate.Text).Year;
                        dbEntry.SubmittedForm4 = rdListSubmittedForm4.SelectedIndex == -1 ? string.Empty : rdListSubmittedForm4.SelectedValue;
                        dbEntry.EntryDate= DateTime.Today;
                        dbEntry.EntryIP= CommonFunctions.GetIpAddress();
                        dbEntry.IsActive= true;
                        dbEntry.EntryId = Convert.ToString(Session["USER_KEY"]);

                        dataContext.Entry(dbEntry).State = EntityState.Modified;
                    }
                    else
                    {
                        var entry = new PersonalInformation
                        {
                            Id=id,
                            PdfFormTemplateId = Guid.Parse(CurrentId),
                            UserId = Convert.ToString(Session["USER_KEY"]),
                            PresentFirstName = txtPresentFirstName.Text,
                            PresentMiddleName = txtPresentMiddleName.Text,
                            PresentLastName = txtPresentLastName.Text,
                            Sex = rdListSex.SelectedIndex == -1 ? string.Empty : rdListSex.SelectedItem.Value,
                            MailAddStreetNo = txtMailAddStreetNo.Text,
                            MailAddPOBox = txtMailAddPOBox.Text,
                            MailAddAptSuitNo = txtMailAddAptSuitNo.Text,
                            MailAddBuzzerNo = txtMailAddBuzzerNo.Text,
                            MailAddCityTownVillage = txtMailAddCityTownVillage.Text,
                            MailAddProvience = txtMailAddProvience.Text,
                            MailAddPostalCode = txtMailAddPostalCode.Text,
                            MailAddHomePhoneCode = txtMailAddHomePhoneCode.Text,
                            MailAddHomePhoneNo = txtMailAddHomePhoneNo.Text,
                            MailAddWorkPhoneCode = txtMailAddWorkPhoneCode.Text,
                            MailAddWorkPhoneNo = txtMailAddWorkPhoneNo.Text,
                            LivedInOntarioYears = string.IsNullOrEmpty(txtLivedInOntarioYears.Text) ? 0 : Convert.ToInt32(txtLivedInOntarioYears.Text),
                            LivedInOntarioMonths = string.IsNullOrEmpty(txtLivedInOntarioMonths.Text) ? 0 : Convert.ToInt32(txtLivedInOntarioMonths.Text),
                            LivedInOntarioPast12Months = rdListLivedInOntarioPast12Months.SelectedIndex == -1 ? string.Empty : rdListLivedInOntarioPast12Months.SelectedValue,
                            DOBYear = string.IsNullOrEmpty(txtDOB.Text) ? 0 : DateTime.ParseExact(txtDOB.Text, "MM/dd/yyyy", null).Year,
                            DOBMonth = string.IsNullOrEmpty(txtDOB.Text) ? 0 : DateTime.ParseExact(txtDOB.Text, "MM/dd/yyyy", null).Month,
                            DOBDay = string.IsNullOrEmpty(txtDOB.Text) ? 0 : DateTime.ParseExact(txtDOB.Text, "MM/dd/yyyy", null).Day,
                            BirthCityTownVillage = txtBirthCityTownVillage.Text,
                            BirthProvinceOrState = txtBirthProvinceOrState.Text,
                            BirthCountry = txtBirthCountry.Text,
                            NewFirstName = txtNewFirstName.Text,
                            NewMiddleName = txtNewMiddleName.Text,
                            NewLastName = txtNewLastName.Text,
                            Married = rdListMarried.SelectedValue,
                            PartnerFisrtName = txtPartnerFisrtName.Text,
                            PartnerMiddleName = txtPartnerMiddleName.Text,
                            PartnerLastName = txtPartnerLastName.Text,
                            DateMarriedMonth = string.IsNullOrEmpty(txtDateMarried.Text) ? 0 : DateTime.ParseExact(txtDateMarried.Text, "MM/dd/yyyy", null).Month,
                            DateMarriedDay = string.IsNullOrEmpty(txtDateMarried.Text) ? 0 : DateTime.ParseExact(txtDateMarried.Text, "MM/dd/yyyy", null).Day,
                            DateMarriedYear = string.IsNullOrEmpty(txtDateMarried.Text) ? 0 : DateTime.ParseExact(txtDateMarried.Text, "MM/dd/yyyy", null).Year,
                            CityTownMarried = txtCityTownMarried.Text,
                            StateOrProvinceMarried = txtStateOrProvinceMarried.Text,
                            CountryMarried = ddlCountryMarried.SelectedIndex == -1 ? string.Empty : ddlCountryMarried.SelectedValue,
                            JDeclarationSigned = rdListJDeclarationSigned.SelectedIndex == -1 ? string.Empty : rdListJDeclarationSigned.SelectedValue,
                            JDeclarationPersonFirstName = txtJDeclarationPersonFirstName.Text,
                            JDeclarationPersonMiddleName = txtJDeclarationPersonMiddleName.Text,
                            JDeclarationPersonLastName = txtJDeclarationPersonLastName.Text,
                            SentRegistrarMonth = string.IsNullOrEmpty(txtSentRegistrarDate.Text) ? 0 : DateTime.ParseExact(txtSentRegistrarDate.Text, "MM/dd/yyyy", null).Month,
                            SentRegistrarDay = string.IsNullOrEmpty(txtSentRegistrarDate.Text) ? 0 : Convert.ToDateTime(txtSentRegistrarDate.Text).Day,
                            SentRegistrarYear = string.IsNullOrEmpty(txtSentRegistrarDate.Text) ? 0 : Convert.ToDateTime(txtSentRegistrarDate.Text).Year,
                            SubmittedForm4 = rdListSubmittedForm4.SelectedIndex == -1 ? string.Empty : rdListSubmittedForm4.SelectedValue,
                            EntryDate = DateTime.Today,
                            EntryIP = CommonFunctions.GetIpAddress(),
                            IsActive = true,
                            EntryId = Convert.ToString(Session["USER_KEY"])
                        };

                        dataContext.PersonalInformations.Add(entry);
                    }
                      
                    dataContext.SaveChanges();

                    returnMessage = "Data submitted successfully!";
                    
                }
            }
            catch (DbEntityValidationException ex)
            {
                returnMessage = ex.EntityValidationErrors.SelectMany(eve => eve.ValidationErrors).Aggregate(returnMessage, (current, ve) => current + (ve.PropertyName + " Error Msg:" + ve.ErrorMessage));
            }

            return returnMessage;
        }
Ejemplo n.º 19
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Session["PKG"] != null)
            {
                try
                {
                    var package = (Package)Session["PKG"];

                    using (var dataContext = new nChangerDb())
                    {
                        var user = dataContext.Users.Find(UserId);
                        if (user != null)
                        {
                            #region Charge....

                            var myCharge = new StripeChargeCreateOptions
                            {
                                Amount = (int)(package.Price * 100),
                                Currency = "usd",
                                Description = "Subscription Charges for " + package.PackageName + " package for " + UserName,
                                Source = new StripeSourceOptions()
                                {
                                    // set these properties if passing full card details (do not
                                    // set these properties if you set TokenId)
                                    Object = "card",
                                    Number = txtCardNumber.Text,
                                    ExpirationYear = txtExpieryYear.Text,
                                    ExpirationMonth = ddlExpiryMonth.SelectedValue,
                                    AddressCountry = user.Country, // optional
                                    AddressLine1 = user.Address, // optional
                                    AddressLine2 = user.Address2, // optional
                                    AddressCity = user.City, // optional
                                    AddressState = user.State, // optional
                                    AddressZip = user.Zip, // optional
                                    Name = UserName, // optional
                                    Cvc = txtCVC.Text, // optional
                                    ReceiptEmail = user.Email
                                },

                                Capture = true
                            };

                            var stripeCharge = new StripeCharge();
                            try
                            {
                                var chargeService = new StripeChargeService(ConfigurationManager.AppSettings["StripeApiKey"]);
                                stripeCharge = chargeService.Create(myCharge);

                                #region Log Entry... 

                                dataContext.UserPayments.Add(new UserPayment
                                {
                                    Id = Guid.NewGuid(),
                                    Amount = (decimal)(stripeCharge.Amount / 100),
                                    Currency = stripeCharge.Currency,
                                    Status = stripeCharge.Status,
                                    FailureCode = stripeCharge.FailureCode,
                                    FailureMessage = stripeCharge.FailureMessage,
                                    PackageId = package.Id,
                                    PaymentDate = stripeCharge.Created,
                                    UserId = UserId,
                                    EntryIP = CommonFunctions.GetIpAddress(),
                                    EntryId = UserId,
                                });


                                if (stripeCharge.Status.ToLower().Equals("succeeded"))
                                    dataContext.Database.ExecuteSqlCommand("UPDATE Users SET IsPaidMember='1' WHERE UserId='" +
                                                                           UserId + "'");
                                 
                                #endregion Log Entry...
                            }
                            catch(Exception error)
                            {
                                dataContext.UserPayments.Add(new UserPayment
                                {
                                    Id = Guid.NewGuid(),
                                    Amount = (decimal)package.Price,
                                    Currency = "usd",
                                    Status = "Failed",
                                    FailureCode = stripeCharge.FailureCode,
                                    FailureMessage = error.Message,
                                    PackageId = package.Id,
                                    PaymentDate = DateTime.Now,
                                    UserId = UserId,
                                    EntryIP = CommonFunctions.GetIpAddress(),
                                    EntryId = UserId,
                                });
                            }

                            #endregion Charge....

                            dataContext.SaveChanges();

                            #region Response...

                            Session.Add("PMS", stripeCharge);

                            Response.Redirect("PaymentResponse.aspx");

                            #endregion Response...

                        }
                    }
                }
                catch (Exception exception)
                {
                    
                }
               
            }

        }
        protected void gvFeature_OnRowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            var id = Guid.Parse(Convert.ToString(gvFeature.DataKeys[e.RowIndex].Values[0]));

            try
            {
                using (var dataContext = new nChangerDb())
                {
                    var dbEntry = dataContext.FeatureMasters.Find(id);

                    dataContext.Database.ExecuteSqlCommand("DELETE FROM PackageFeature WHERE FeatureId='" + id + "'");
                    dataContext.FeatureMasters.Remove(dbEntry);
                    dataContext.SaveChanges();
                    lblMsg.Text = "Feature " + dbEntry.Feature + " deleted successfully.";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "showAlert()", true);
                    BindFeatures();
                }
            }
            catch (Exception exception)
            {
                lblMsg.Text = exception.Message;
            }
        }
        protected void btnSubmit_OnClick(object sender, EventArgs e)
        {
            divMsg.InnerText = Submit();
            var sections = Sections;
            var page = Path.GetFileName(Request.PhysicalPath);
            var curret = Sections.FirstOrDefault(s => s.AspxPath.Contains(page));

            using (var dataContext = new nChangerDb())
            {
                dataContext.Database.ExecuteSqlCommand("DELETE FROM UserFormDetail WHERE UserId='" + UserId +
                                                       "' AND PdfTemplateId='" + CurrentId + "'  AND FrmGuid='" +
                                                       curret.FrmGuid.ToString() + "'");

                dataContext.UserFormDetails.AddOrUpdate(new UserFormDetail
                {
                    Id = Guid.NewGuid(),
                    UserId = UserId,
                    AspxPath = curret.AspxPath,
                    TableName = curret.TableName,
                    PdfTemplateId = Guid.Parse(CurrentId),
                    FrmGuid = curret.FrmGuid,
                    Completed = "Y"
                });

                dataContext.SaveChanges();
            }

            Response.Redirect("../Secured/FormCompleted.aspx");
        }
        public bool Submit()
        {
            var returnMessage = string.Empty;
            var success = true;
            var id = string.IsNullOrEmpty(hidFeatureId.Value) ? Guid.NewGuid() : Guid.Parse(hidFeatureId.Value);
            try
            {

                var message = string.Empty;

                using (var dataContext = new nChangerDb())
                {
                    var feature = new FeatureMaster()
                    {
                        Id = id,
                        Feature = hidFeatureName.Value,
                        Description = hidFeatureDesc.Value,
                        IsActive = true,
                        EntryDate = DateTime.Now,
                        EntryIP = CommonFunctions.GetIpAddress(),
                        EntryId = UserId
                    };

                    dataContext.FeatureMasters.AddOrUpdate(feature);
                    dataContext.SaveChanges();

                    lblMsg.Text = "Feature \"" + feature.Feature + "\" " + (string.IsNullOrEmpty(hidFeatureId.Value) ? "added" : "updated") + " successfully.";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "showAlert()", true);
                     
                }

            }
            catch (DbEntityValidationException ex)
            {
                success = false;
                returnMessage = ex.EntityValidationErrors.SelectMany(eve => eve.ValidationErrors).Aggregate(returnMessage, (current, ve) => current + (ve.PropertyName + " Error Msg:" + ve.ErrorMessage));
            }
            
            return success;
        }
Ejemplo n.º 23
0
        private void UploadPdf(string file)
        {
            try
            { 
                using (var dataContext = new nChangerDb())
                {
                    dataContext.PdfTemplates.Add(new PdfTemplate
                    {
                        Id = Guid.NewGuid(),
                        PdfFileName = file,
                        TemplateName = file,
                        EntryIP = CommonFunctions.GetIpAddress(),
                        EntryId = UserId,
                        EntryDate = DateTime.Now,
                        IsActive = false,
                    });

                    dataContext.SaveChanges();
                   
                }
            }
            catch (DbEntityValidationException ex)
            {
                foreach (var eve in ex.EntityValidationErrors)
                {
                    lblMsg.Text += eve.Entry.Entity.GetType().Name + "<br/>" + eve.Entry.State;
                    foreach (var ve in eve.ValidationErrors)
                    {
                        lblMsg.Text += ve.PropertyName + "<br/>" + ve.ErrorMessage;
                    }
                }
            }
             
        }
        private string Submit()
        {
            var id = Guid.Parse(RecordId);
            var returnMessage = string.Empty;
            try
            {
                using (var dataContext = new nChangerDb())
                {
                    var dbEntry = dataContext.NameChangeInformations.Find(id);
                     
                    if (dbEntry != null)
                    {
                        dbEntry.ResonForNameChange = txtResonForNameChange.Text;
                        dbEntry.ChangedNamePriviously = rdListChangedNamePriviously.SelectedIndex != -1
                            ? rdListChangedNamePriviously.SelectedValue:string.Empty;

                        dbEntry.UserId = UserId;
                        dbEntry.PreviousNameChangeDay = string.IsNullOrEmpty(txtPreviousNameChangeDate.Text) ? 0 : DateTime.ParseExact(txtPreviousNameChangeDate.Text, "MM/dd/yyyy", null).Day;
                        dbEntry.PreviousNameChangeMonth = string.IsNullOrEmpty(txtPreviousNameChangeDate.Text) ? 0 : DateTime.ParseExact(txtPreviousNameChangeDate.Text, "MM/dd/yyyy", null).Month;
                        dbEntry.PreviousNameChangeYear = string.IsNullOrEmpty(txtPreviousNameChangeDate.Text) ? 0 : DateTime.ParseExact(txtPreviousNameChangeDate.Text, "MM/dd/yyyy", null).Year;
                        dbEntry.PreviousFirstName = txtPreviousFirstName.Text;
                        dbEntry.PreviousMiddleName = txtPreviousMiddleName.Text;
                        dbEntry.PreviousLastName = txtPreviousLastName.Text;
                        dbEntry.FirstNameAfterChange = txtFirstNameAfterChange.Text;
                        dbEntry.MiddleNameAfterChange = txtMiddleNameAfterChange.Text;
                        dbEntry.LastNameAfterChange = txtLastNameAfterChange.Text;
                        dbEntry.PreviousNameChangeProvince = txtPreviousNameChangeProvince.Text;
                        dbEntry.PreviousNameChangeCountry = ddlCountry.SelectedIndex != -1 ? ddlCountry.SelectedValue:string.Empty;
                        dbEntry.AppliedForChangeAndRefused = rdLstAppliedForChangeAndRefused.SelectedIndex == 0;
                        dbEntry.EntryDate = DateTime.Today;
                        dbEntry.EntryIP = CommonFunctions.GetIpAddress();
                        dbEntry.IsActive = true;
                        dbEntry.EntryId = UserId;

                        dataContext.Entry(dbEntry).State = EntityState.Modified;
                    }
                    else
                    {
                        var entry = new NameChangeInformation()
                        {
                            Id =id,
                            PdfFormTemplateId = Guid.Parse(CurrentId),
                            UserId = UserId,
                            ResonForNameChange = txtResonForNameChange.Text,
                            ChangedNamePriviously = rdListChangedNamePriviously.SelectedIndex != -1? rdListChangedNamePriviously.SelectedValue:string.Empty,
                            PreviousNameChangeDay = string.IsNullOrEmpty(txtPreviousNameChangeDate.Text) ? 0 : DateTime.ParseExact(txtPreviousNameChangeDate.Text, "MM/dd/yyyy", null).Day,
                            PreviousNameChangeMonth = string.IsNullOrEmpty(txtPreviousNameChangeDate.Text) ? 0 : DateTime.ParseExact(txtPreviousNameChangeDate.Text, "MM/dd/yyyy", null).Month,
                            PreviousNameChangeYear = string.IsNullOrEmpty(txtPreviousNameChangeDate.Text) ? 0 : DateTime.ParseExact(txtPreviousNameChangeDate.Text, "MM/dd/yyyy", null).Year,
                            PreviousFirstName = txtPreviousFirstName.Text,
                            PreviousMiddleName = txtPreviousMiddleName.Text,
                            PreviousLastName = txtPreviousLastName.Text,
                            FirstNameAfterChange = txtFirstNameAfterChange.Text,
                            MiddleNameAfterChange = txtMiddleNameAfterChange.Text,
                            LastNameAfterChange = txtLastNameAfterChange.Text,
                            PreviousNameChangeProvince = txtPreviousNameChangeProvince.Text,
                            PreviousNameChangeCountry = ddlCountry.SelectedIndex != -1 ? ddlCountry.SelectedValue:string.Empty,
                            AppliedForChangeAndRefused = rdLstAppliedForChangeAndRefused.SelectedIndex == 0,
                            EntryDate = DateTime.Today,
                            EntryIP = CommonFunctions.GetIpAddress(),
                            IsActive = true,
                            EntryId = UserId
                        };

                        dataContext.NameChangeInformations.Add(entry);
                    }

                    dataContext.SaveChanges();

                    returnMessage = "Data submitted successfully!";
                    
                }
            }
            catch (DbEntityValidationException ex)
            {
                returnMessage = ex.EntityValidationErrors.SelectMany(eve => eve.ValidationErrors).Aggregate(returnMessage, (current, ve) => current + (ve.PropertyName + " Error Msg:" + ve.ErrorMessage));
            }

            return returnMessage;
        }