public IHttpActionResult CompanyRegister(CompanyDetailsEntities company) { try { if (company.UserId > 0) { company.IsActive = true; company.CreatedDate = DateTime.Now; company.CopmanyAddress1 = company.City; company.CopmanyAddress2 = company.City; var data = db.UserRegistrations.Where(m => m.Id == company.UserId).FirstOrDefault(); string FilePath = "D:\\CargovioProject\\Cargovio\\Common\\MailFormat\\CompanyRegistration.html"; StreamReader str = new StreamReader(FilePath); string MailText = str.ReadToEnd(); DateTime time = DateTime.Now; MailText = MailText.Replace("{UserName}", data.Username); MailText = MailText.Replace("{CompanyName}", company.CompanyName); str.Close(); MailMessage mail = new MailMessage(); mail.To.Add(data.Email); mail.From = new MailAddress("*****@*****.**"); mail.Subject = "Company Registration Success"; string Body = MailText; mail.Body = Body; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Password@123"); smtp.EnableSsl = true; smtp.Send(mail); string Message = data.Username + " Your Company " + company.CompanyName + " Is Register With Cargovio.in Now You Login With You LoginID" + data.Email; sms.Send(data.ContactNo, Message); return(Ok(userManager.CompanyDetails(company))); } else { return(Ok("Please Register First!")); } } catch (Exception ex) { return(Ok(ex)); } }
public CompanyDetailsEntities StartNewFinancialYear(string status) { CompanyDetailsEntities Message = new CompanyDetailsEntities(); try { Message = entites.Database.SqlQuery <CompanyDetailsEntities>("StartNewFinancialYear @Message", new SqlParameter("Message", status)).SingleOrDefault(); } catch (Exception) { throw; } return(Message); }
public CompanyDetailsEntities GetCompanyDetails() { //CompanyDetailsEntities result = new CompanyDetailsEntities(); ICompanyBL companyBL = new CompanyBL(); CompanyDetailsEntities result = companyBL.GetCompanyDetails(); //foreach (products.Product source in productList) //{ // ProductEntity target = new ProductEntity(); // target.ProductID = source.ProductID; // target.Category = source.Category; // target.SubCategory = source.Subcategory; // target.Model = source.Model; // target.Product = source.Product1; // result.Add(target); //} return(result); }
public bool CompanyDetails(CompanyDetailsEntities objCompany) { try { var config = new MapperConfiguration(cfg => cfg.CreateMap <CompanyDetailsEntities, CompanyDetail>()); IMapper mapper = config.CreateMapper(); bool IsAvailable = userRepository.CheckCompany(objCompany.UserId, objCompany.CompanyName); if (IsAvailable == false) { CompanyDetail company = mapper.Map <CompanyDetailsEntities, CompanyDetail>(objCompany); return(userRepository.AddCompanyDetails(company)); } else { return(false);; } } catch (DataMisalignedException ex) { throw; } }
//public void LoadCountry() //{ // _countrycombo = new ObservableCollection<Country>(_objDataSource.CountryList()); //} //ObservableCollection<StateDropDown> StateListing = new ObservableCollection<StateDropDown>(); //public void LoadState(string countrycode) //{ // ICompanyDetails CompanyDetails = new CompanyDetails(); // StateListing = new ObservableCollection<StateDropDown> // (from state in CompanyDetails.GetStates() // where state.CountryCode.Equals(countrycode) // select state); // Mouse.OverrideCursor = Cursors.Wait; // //this.SingleStateList.Add(StateDropDown)e.User; // BackgroundWorker worker = new BackgroundWorker(); // //Set the WorkerReportsProgress property to true if you want the BackgroundWorker to support progress updates. // //When this property is true, user code can call the ReportProgress method to raise the ProgressChanged event. // worker.WorkerReportsProgress = true; // //This event is raised when you call the RunWorkerAsync method. This is where you start the time-consuming operation. // worker.DoWork += new DoWorkEventHandler(this.LoadProductsBackgroundState); // // This event is raised when you call the ReportProgress method. // worker.ProgressChanged += new ProgressChangedEventHandler(this.LoadProductsBackgroundProgressState); // //The RunWorkerCompleted event is raised when the background worker has completed. // //Depending on whether the background operation completed successfully, encountered an error, // //or was canceled, update the user interface accordingly // worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.LoadProductsBackgroundCompleteState); // //Starts running a background operation // worker.RunWorkerAsync(); // //this.LoadProductsBackgroundProgressState(object, ProgressChangedEventArgs e); // this.OnPropertyChanged("SingleStateList"); //} #region Background Worker /// <summary> /// Loads the product models background. /// </summary> public void LoadCompanyBackground() { //int compId = 0; Mouse.OverrideCursor = Cursors.Wait; SelectedCompany = null; // Unselects last selection. Essential, as assignment below won't clear other control's SelectedItems var Company = new CompanyDetailsEntities(); ICompanyDetails CompanyDetails = new CompanyDetails(); var results = CompanyDetails.GetCompanyDetails(); if (results != null) { compId = results.ID; companyname = results.CompanyName; compDetailsbackup = results; } else { CompanyName = "Please setup your company details"; } //var shippingdetails = CompanyDetails.GetShippingDetails(compId, "Company"); //results.ShippingAddress = shippingdetails; if (results.Comp_logo != null && results.Comp_logo.Length > 0) { Bitmap imageBitMap = BytesToBitmap(results.Comp_logo); //Bitmap bitmap = (Bitmap)Bitmap.FromFile(@"C:\Users\Ashutosh Dwivedi\Desktop\Motivationla.jpg", true); results.ButtonSource = BitmapConversion.BitmapToBitmapSource(imageBitMap); } else { Bitmap imageBitMap = BytesToBitmap(Default_photo_aray); //Bitmap bitmap = (Bitmap)Bitmap.FromFile(@"C:\Users\Ashutosh Dwivedi\Desktop\Motivationla.jpg", true); results.ButtonSource = BitmapConversion.BitmapToBitmapSource(imageBitMap); } int minHeight = 300; var height = System.Windows.SystemParameters.PrimaryScreenHeight - 155; bool validHeight = int.TryParse(height.ToString(), out minHeight); results.CompGridHeight = minHeight; SelectedCompany = results; Mouse.OverrideCursor = null; Mouse.OverrideCursor = Cursors.Wait; ////run time-consuming operations on a background thread BackgroundWorker worker = new BackgroundWorker(); ////Set the WorkerReportsProgress property to true if you want the BackgroundWorker to support progress updates. ////When this property is true, user code can call the ReportProgress method to raise the ProgressChanged event. worker.WorkerReportsProgress = true; ////This event is raised when you call the RunWorkerAsync method. This is where you start the time-consuming operation. worker.DoWork += new DoWorkEventHandler(this.LoadProductsBackground); //// This event is raised when you call the ReportProgress method. worker.ProgressChanged += new ProgressChangedEventHandler(this.LoadProductsBackgroundProgress); ////The RunWorkerCompleted event is raised when the background worker has completed. ////Depending on whether the background operation completed successfully, encountered an error, ////or was canceled, update the user interface accordingly worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.LoadProductsBackgroundComplete); ////Starts running a background operation worker.RunWorkerAsync(); }
public bool AddCompanyDAL(CompanyDetailsEntities companyDetail) { using (var ts = entites.Database.BeginTransaction()) { try { CompanyDetail result = entites.CompanyDetails.FirstOrDefault();// query.ToList(); if (result != null) { result.Comp_Email = companyDetail.Comp_Email; result.Comp_Fax = companyDetail.Comp_Fax; result.Comp_GST_Dereg_Date = companyDetail.Comp_GST_Dereg_Date == null ? null as DateTime? : Convert.ToDateTime(companyDetail.Comp_GST_Dereg_Date); result.Comp_GST_Reg_Date = companyDetail.Comp_GST_Reg_Date == null ? null as DateTime? : Convert.ToDateTime(companyDetail.Comp_GST_Reg_Date); result.Comp_GST_Reg_No = companyDetail.Comp_GST_Reg_No; result.Comp_Logo = companyDetail.Comp_logo; result.Comp_Name = companyDetail.CompanyName; result.Comp_Reg_No = companyDetail.Comp_Reg_No; result.Comp_Tel = companyDetail.Comp_Tel; result.Comp_year_end_date = companyDetail.Comp_year_end_date == null ? null as DateTime? : Convert.ToDateTime(companyDetail.Comp_year_end_date); result.Comp_year_start_date = companyDetail.Comp_year_start_date == null ? null as DateTime? : Convert.ToDateTime(companyDetail.Comp_year_start_date); result.CreatedBy = 0; result.CreatedDate = DateTime.Now; result.Software_Ser_No = companyDetail.Software_Ser_No; result.Comp_Bill_to_city = companyDetail.Company_BillTo_City; result.Comp_Bill_to_country = companyDetail.Company_BillTo_Country; result.Comp_Bill_to_line1 = companyDetail.Company_BillTo_Line1; result.Comp_Bill_to_line2 = companyDetail.Company_BillTo_Line2; result.Comp_Bill_to_post_code = companyDetail.Company_BillTo_PostalCode; result.Comp_Bill_to_state = companyDetail.Company_BillTo_State; result.Comp_Ship_to_city = companyDetail.ShipTo_City; result.Comp_Ship_to_country = companyDetail.ShipTo_Country; result.Comp_Ship_to_line1 = companyDetail.ShipTo_Line1; result.Comp_Ship_to_line2 = companyDetail.ShipTo_Line2; result.Comp_Ship_to_post_code = companyDetail.ShipTo_PostalCode; result.Comp_Ship_to_state = companyDetail.ShipTo_State; entites.SaveChanges(); //if (companyDetail.ShippingID != 0) //{ // ShippingAddress editshipadd = entites.ShippingAddresses.Where(x => x.ID == companyDetail.ShippingID).FirstOrDefault(); // if (editshipadd!=null) // { // editshipadd.Ship_to_city = companyDetail.ShipTo_City; // editshipadd.Ship_to_country = companyDetail.ShipTo_Country; // editshipadd.Ship_to_line1 = companyDetail.ShipTo_Line1; // editshipadd.Ship_to_line2 = companyDetail.ShipTo_Line2; // editshipadd.Ship_to_post_code = companyDetail.ShipTo_PostalCode; // editshipadd.Ship_to_state = companyDetail.ShipTo_State; // entites.SaveChanges(); // } //} //else //{ // if (companyDetail.ShipTo_City != null|| companyDetail.ShipTo_Country!=null|| companyDetail.ShipTo_Line1 !=null|| companyDetail.ShipTo_Line2!=null) // { // ShippingAddress shipaddress = new ShippingAddress() // { // Ship_to_city = companyDetail.ShipTo_City, // EntityId = companyDetail.ID, // EntityType = "Company", // Ship_to_country = companyDetail.ShipTo_Country, // Ship_to_line1 = companyDetail.ShipTo_Line1, // Ship_to_line2 = companyDetail.ShipTo_Line2, // Ship_to_post_code = companyDetail.ShipTo_PostalCode, // Ship_to_state = companyDetail.ShipTo_State // }; // entites.ShippingAddresses.Add(shipaddress); // entites.SaveChanges(); // } //} ts.Commit(); return(true); } else { CompanyDetail CompDetail = new CompanyDetail() { Comp_Email = companyDetail.Comp_Email, Comp_Fax = companyDetail.Comp_Fax, Comp_GST_Dereg_Date = companyDetail.Comp_GST_Dereg_Date == null ? null as DateTime? : Convert.ToDateTime(companyDetail.Comp_GST_Dereg_Date), Comp_GST_Reg_Date = companyDetail.Comp_GST_Reg_Date == null ? null as DateTime? : Convert.ToDateTime(companyDetail.Comp_GST_Reg_Date), Comp_GST_Reg_No = companyDetail.Comp_GST_Reg_No, Comp_Logo = companyDetail.Comp_logo, Comp_Name = companyDetail.CompanyName, Comp_Reg_No = companyDetail.Comp_Reg_No, Comp_Tel = companyDetail.Comp_Tel, Comp_year_end_date = companyDetail.Comp_year_end_date == null ? null as DateTime? : Convert.ToDateTime(companyDetail.Comp_year_end_date), Comp_year_start_date = companyDetail.Comp_year_start_date == null ? null as DateTime? : Convert.ToDateTime(companyDetail.Comp_year_start_date), CreatedBy = 0, CreatedDate = DateTime.Now, Software_Ser_No = companyDetail.Software_Ser_No, Comp_Bill_to_city = companyDetail.Company_BillTo_City, Comp_Bill_to_country = companyDetail.Company_BillTo_Country, Comp_Bill_to_line1 = companyDetail.Company_BillTo_Line1, Comp_Bill_to_line2 = companyDetail.Company_BillTo_Line2, Comp_Bill_to_post_code = companyDetail.Company_BillTo_PostalCode, Comp_Bill_to_state = companyDetail.Company_BillTo_State, Comp_Ship_to_city = companyDetail.ShipTo_City, Comp_Ship_to_country = companyDetail.ShipTo_Country, Comp_Ship_to_line1 = companyDetail.ShipTo_Line1, Comp_Ship_to_line2 = companyDetail.ShipTo_Line2, Comp_Ship_to_post_code = companyDetail.ShipTo_PostalCode, Comp_Ship_to_state = companyDetail.ShipTo_State }; entites.CompanyDetails.Add(CompDetail); entites.SaveChanges(); //autoID = CompDetail.ID; //ShippingAddress shipaddress = new ShippingAddress() //{ // Ship_to_city = companyDetail.ShipTo_City, // EntityId = autoID, // EntityType = "Company", // Ship_to_country = companyDetail.ShipTo_Country, // Ship_to_line1 = companyDetail.ShipTo_Line1, // Ship_to_line2 = companyDetail.ShipTo_Line2, // Ship_to_post_code = companyDetail.ShipTo_PostalCode, // Ship_to_state = companyDetail.ShipTo_State //}; //entites.ShippingAddresses.Add(shipaddress); //entites.SaveChanges(); ts.Commit(); return(true); } } catch (Exception ex) { ts.Rollback(); return(false); throw ex; } } }
public CompanyDetailsEntities GetCompanyDetails() { CompanyDetailsEntities result = new CompanyDetailsEntities(); //ObjectQuery<Product> products = entites.Products; //products.MergeOption = MergeOption.NoTracking; //IQueryable<Product> query = from product in products select product; CompanyDetail source = entites.CompanyDetails.FirstOrDefault();// query.ToList(); if (source != null) { result.ID = source.ID; result.CompanyName = source.Comp_Name; result.Company_BillTo_City = source.Comp_Bill_to_city; result.Company_BillTo_Country = source.Comp_Bill_to_country; result.Company_BillTo_Line1 = source.Comp_Bill_to_line1; result.Company_BillTo_Line2 = source.Comp_Bill_to_line2; result.Company_BillTo_PostalCode = source.Comp_Bill_to_post_code; result.Company_BillTo_State = source.Comp_Bill_to_state; result.Comp_Email = source.Comp_Email; result.Comp_Fax = source.Comp_Fax; result.Comp_GST_Dereg_Date = source.Comp_GST_Dereg_Date; result.Comp_GST_Reg_Date = source.Comp_GST_Reg_Date; result.Comp_GST_Reg_No = source.Comp_GST_Reg_No; result.Comp_logo = source.Comp_Logo; result.Comp_Reg_No = source.Comp_Reg_No; result.Comp_Tel = source.Comp_Tel; result.Comp_year_end_date = source.Comp_year_end_date; result.Comp_year_start_date = source.Comp_year_start_date; result.Software_Ser_No = source.Software_Ser_No; result.ShipTo_City = source.Comp_Ship_to_city; result.ShipTo_Country = source.Comp_Ship_to_country; result.ShipTo_Line1 = source.Comp_Ship_to_line1; result.ShipTo_Line2 = source.Comp_Ship_to_line2; result.ShipTo_PostalCode = source.Comp_Ship_to_post_code; result.ShipTo_State = source.Comp_Ship_to_state; var DateFormatResult = entites.Options.FirstOrDefault(); if (DateFormatResult != null) { result.DateFormat = DateFormatResult.Date_Format; } else { result.DateFormat = null; } var TaxInfo = entites.TaxCodesAndRates.FirstOrDefault(); if (TaxInfo != null) { result.Tax_Name = TaxInfo.Tax_Name; } else { result.Tax_Name = "GST"; } //var companyId = source.ID; //result.ShippAddressCount = entites.ShippingAddresses.Where(x => x.EntityId == companyId && x.EntityType == "Company").Count(); //var shippingdetails = entites.ShippingAddresses.Where(x => x.EntityId == companyId && x.EntityType == "Company").FirstOrDefault(); //if (shippingdetails != null) //{ // result.ShipTo_City = shippingdetails.Ship_to_city; // result.ShipTo_Country = shippingdetails.Ship_to_country; // result.ShipTo_Line1 = shippingdetails.Ship_to_line1; // result.ShipTo_Line2 = shippingdetails.Ship_to_line2; // result.ShipTo_PostalCode = shippingdetails.Ship_to_post_code; // result.ShipTo_State = shippingdetails.Ship_to_state; //} } return(result); }
//private List<string> FlattenErrors() //{ // List<string> errors = new List<string>(); // Dictionary<string, List<string>> allErrors = taxM.GetAllErrors(); // foreach (string propertyName in allErrors.Keys) // { // foreach (var errorString in allErrors[propertyName]) // { // errors.Add(errorString); // } // } // return errors; //} private void SaveTax() { ITaxOperationRepository taxRepository = new TaxOperationRepository(); ITaxCodesAndRatesRepository tax = new TaxCodesAndRatesRepository(); ICompanyDetails details = new CompanyDetails(); var taxModel = SelectedTax as TaxModel; if (SelectedTaxName != null) { taxModel.TaxName = SelectedTaxName; } if (taxModel != null) { TaxErrors = ValidateTaxCodesAndRates(taxModel); if (TaxErrors == string.Empty) { MessageBoxResult result = MessageBox.Show("Do you want to save changes?", "Save Tax", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { CompanyDetailsEntities compEntities = details.GetCompanyDetails(); if (compEntities.Comp_Reg_No == null) { if (taxModel.Predefined == false) { if (taxModel.IsDefault == true) { MessageBox.Show("Your Company is not registered to collect GST/VAT.\n" + "@ Simple Accounting Software Pte Ltd", "Warning Message", MessageBoxButton.OK); } } } else { if (compEntities.Comp_GST_Dereg_Date != null) { if (Convert.ToDateTime(compEntities.Comp_GST_Dereg_Date).Date > DateTime.Now.Date) { if (taxModel.Predefined == false) { if (taxModel.IsDefault == true) { MessageBox.Show("Your Company is not registered to collect GST/VAT.\n" + "@ Simple Accounting Software Pte Ltd", "Warning Message", MessageBoxButton.OK); } } } } } if (taxModel.Predefined == true) { if (taxModel.TaxRate != 0 || taxModel.IsInActive == "Y") { TaxErrors = "# GST Free cannot be made inactive. Description and Code can be edited but not rate."; Mouse.OverrideCursor = null; return; } } if (taxRepository.IsCodeAndRateExists(taxModel)) { TaxErrors = "Tax Code should be unique"; Mouse.OverrideCursor = null; return; } else { if (SelectedIndex == -1) { taxRepository.SaveTax(taxModel); } else { taxRepository.UpdateTax(taxModel); } } //MessageBox.Show("Record Saved successfully", "Save Content", MessageBoxButton.OK); Tax = new ObservableCollection <TaxModel>(tax.GetAllTaxes()); SelectedTax = null; TaxErrors = string.Empty; } } } }