protected void LoadItems()
        {
            if (!HasEditPermission)
            {
                dgAppUsers.Columns[dgAppUsers.Columns.Count - 1].Visible = false;
            }
            string   searchName = "%" + txtSearchName.Text.Trim() + "%";
            string   searchPhone = "%" + txtSearchPhone.Text.Trim() + "%";
            DateTime from, to = new DateTime();

            DateTime.TryParse(dpSearchCreateDateFrom.Value.ToString(), out from);
            DateTime.TryParse(dpSearchCreateDateTo.Value.ToString(), out to);


            dgAppUsers.VirtualItemCount = AppUserUI.GetAllAppUserUI(from, to, searchName, searchPhone).Count;
            if (dgAppUsers.VirtualItemCount == 0)
            {
                phHasItems.Visible   = false;
                phHasNoItems.Visible = true;
                lblNoItems.Text      = AppUsersStrings.GetText(@"MessageNoUsersFound");
            }
            else
            {
                phHasItems.Visible   = true;
                phHasNoItems.Visible = false;
                if (dgAppUsers.PageSize * dgAppUsers.CurrentPageIndex > dgAppUsers.VirtualItemCount)
                {
                    dgAppUsers.CurrentPageIndex         = 0;
                    hfCurrentPageIndex_dgAppUsers.Value = dgAppUsers.CurrentPageIndex.ToString();
                }
                List <AppUserUI> app_users = AppUserUI.GetAllAppUserUI(from, to, searchName, searchPhone, dgAppUsers.PageSize, dgAppUsers.CurrentPageIndex);
                BindList(app_users);
            }
        }
Beispiel #2
0
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         //Delete AppUser Token
         try
         {
             new Query(AppUserAuthToken.TableSchema).Delete().Where(AppUserAuthToken.Columns.AppUserId, AppUserId).Execute();
             new Query(AppUserAPNSToken.TableSchema).Delete().Where(AppUserAPNSToken.Columns.AppUserId, AppUserId).Execute();
             new Query(AppUserGcmToken.TableSchema).Delete().Where(AppUserGcmToken.Columns.AppUserId, AppUserId).Execute();
             Query.New <AppUser>().Where(AppUser.Columns.AppUserId, AppUserId)
             .Update(AppUser.Columns.IsDeleted, true)
             .Update(AppUser.Columns.UniqueIdString, null)
             .Update(AppUser.Columns.FacebookId, null)
             .Execute();
         }
         catch
         {
         }
         Master.MessageCenter.DisplaySuccessMessage(AppUsersStrings.GetText(@"MessageAppUserDeleted"));
         lblDeleteConfirm.Visible = false;
         chkDeleteConfirm.Visible = false;
         btnDelete.Visible        = false;
     }
 }
        protected void Page_Init(object sender, EventArgs e)
        {
            HasEditPermission = Permissions.PermissionsForUser(SessionHelper.UserId()).Contains(Permissions.PermissionKeys.sys_perm);

            Master.AddButtonNew(AppUsersStrings.GetText(@"NewAppUserButton"), @"EditAppUser.aspx?New=yes", new string[] { Permissions.PermissionKeys.sys_perm });

            dgAppUsers.PageIndexChanged += dgAppUsers_PageIndexChanging;
        }
Beispiel #4
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            Master.PageTitle  = AppUsersStrings.GetText(IsNewMode ? @"NewAppUserPageTitle" : @"EditAppUserPageTitle");
            Master.ActiveMenu = IsNewMode ? "NewAppUser" : "AppUsers";
            Master.AddClientScriptInclude(@"dgDatePicker.js");

            //trCurrentPassword.Visible = !IsNewMode && AppUserId == SessionHelper.UserId();
            rfvPasswordRequired.Visible        = rfvPasswordRequired.Enabled = IsNewMode;
            rfvConfirmPasswordRequired.Visible = rfvConfirmPasswordRequired.Enabled = IsNewMode;
        }
        protected void btnExport_Click(object sender, EventArgs e)
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"Email"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"FirstName"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"LastName"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"IsLocked"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"Phone"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"Address"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"IsAdv"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"LastLogin"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"CreateDate"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"UserId"), typeof(string)));

            string   searchName = "%" + txtSearchName.Text.Trim() + "%";
            string   searchPhone = "%" + txtSearchPhone.Text.Trim() + "%";
            DateTime from, to = new DateTime();

            DateTime.TryParse(dpSearchCreateDateFrom.Value.ToString(), out from);
            DateTime.TryParse(dpSearchCreateDateTo.Value.ToString(), out to);

            List <AppUserUI> app_users = AppUserUI.GetAllAppUserUI(from, to, searchName, searchPhone);

            foreach (AppUserUI appUser in app_users)
            {
                System.Data.DataRow row = dt.NewRow();
                row[0] = appUser.Email;
                row[1] = appUser.FirstName;
                row[2] = appUser.LastName;
                row[3] = GlobalStrings.GetYesNo(appUser.IsLocked);
                row[4] = "\"" + appUser.Phone + "\"";
                row[5] = appUser.Street + " " + appUser.HouseNum + "\n"
                         + AppUsersStrings.GetText(@"Floor") + " " + appUser.Floor + "\n"
                         + AppUsersStrings.GetText(@"ApartmentNumber") + " " + appUser.ApartmentNumber + "\n"
                         + appUser.CityName;
                row[6] = GlobalStrings.GetYesNo(appUser.IsAdv);
                row[7] = "\"" + appUser.LastLogin + "\"";
                row[8] = "\"" + appUser.CreateDate + "\"";
                row[9] = "\"" + appUser.AppUserId + "\"";

                dt.Rows.Add(row);
            }

            SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, false, true);

            Response.Clear();
            Response.AddHeader(@"content-disposition", @"attachment;filename=AppUsersExport_" + DateTime.UtcNow.ToString(@"yyyy_MM_dd_HH_mm_ss") + "." + ex.FileExtension);
            Response.Charset         = @"UTF-8";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = ex.FileContentType;
            Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());
            Response.Write(ex.ToString());
            Response.End();
        }
Beispiel #6
0
        protected void btnExportForCRM_Click(object sender, EventArgs e)
        {
            System.Data.DataTable dt = new System.Data.DataTable();

            dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"SupplierId"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"BusinessName"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"SupplierServices"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"Address"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"CityName"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"Phone"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"ContactPhone"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"ContactName"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"Email"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(SuppliersStrings.GetText(@"SupplierType"), typeof(string)));

            List <SupplierUI> suppliers   = new List <SupplierUI>();
            string            searchName  = "%" + txtSearchName.Text.Trim() + "%";
            string            searchPhone = "%" + txtSearchPhone.Text.Trim() + "%";

            suppliers = SupplierController.GetAllSuppliersUI(true, searchName, searchPhone);

            foreach (SupplierUI supplier in suppliers)
            {
                int i = 0;
                System.Data.DataRow row = dt.NewRow();
                row[i++] = supplier.SupplierId;
                row[i++] = supplier.BusinessName;

                row[i++] = getSupplierServices(supplier);
                row[i++] = supplier.Street + " " + supplier.HouseNum;
                row[i++] = supplier.CityName;
                row[i++] = "=\"" + supplier.Phone + "\"";
                row[i++] = "=\"" + supplier.ContactPhone + "\"";
                row[i++] = supplier.ContactName;
                row[i++] = supplier.Email;
                row[i++] = supplier.IsProduct ? SuppliersStrings.GetText(@"IsProduct") : SuppliersStrings.GetText(@"IsService");
                dt.Rows.Add(row);
            }
            System.Data.DataRow sumRow = dt.NewRow();
            sumRow[0] = SuppliersStrings.GetText(@"SumSumPerMonth") + " " + suppliers.Sum(o => o.SumPerMonth);
            dt.Rows.Add(sumRow);
            SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, false, true);

            Response.Clear();
            Response.AddHeader(@"content-disposition", @"attachment;filename=SuppliersExportForCRM_" + DateTime.UtcNow.ToString(@"yyyy_MM_dd_HH_mm_ss") + "." + ex.FileExtension);
            Response.Charset         = @"UTF-8";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = ex.FileContentType;
            Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());
            Response.Write(ex.ToString());
            Response.End();
        }
Beispiel #7
0
        protected void btnImport_Click(object sender, EventArgs e)
        {
            if (CsvDataTable != null)
            {
                int count = 0;
                try
                {
                    foreach (DataRow appUserRow in CsvDataTable.Rows)
                    {
                        if (appUserRow["Comments"].ToString() == "")
                        {
                            AppUser app_user = null;
                            AppMembership.AppUserCreateResults results = AppMembership.CreateAppUser(appUserRow["Email"].ToString(), appUserRow["Password"].ToString(), @"", out app_user);
                            if (results != AppMembership.AppUserCreateResults.Success)
                            {
                                throw new Exception();
                            }
                            app_user.FirstName = appUserRow["FirstName"].ToString();
                            app_user.LastName  = appUserRow["LastName"].ToString();
                            app_user.IsLocked  = appUserRow["IsLocked"].ToString() == "0" ? false : true;;
                            app_user.Phone     = appUserRow["Phone"].ToString();
                            // app_user.OrderDisplay = OrderDisplay.GetLastOrder() + 1;

                            app_user.Save();
                            count++;
                        }
                    }
                    lblImportResult.Text = AppUsersStrings.GetText(@"MessageImportSuccess");
                }
                catch
                {
                    lblImportResult.Text = AppUsersStrings.GetText(@"MessageImportFailedUnknown");
                }
                phImportResult.Visible = true;
                lblTotalImported.Text  = count.ToString();
                btnImport.Enabled      = false;
                phErrors.Visible       = false;
                phAppUsersList.Visible = false;
            }
        }
Beispiel #8
0
        protected void btnAcceptFile_Click(object sender, EventArgs e)
        {
            if (fuImportFile.HasFile)
            {
                string[] allowedFileTypes = { "text/csv", "application/vnd.ms-excel" };
                if (allowedFileTypes.Contains(fuImportFile.PostedFile.ContentType))
                {
                    string filename     = Path.GetRandomFileName() + "_" + Path.GetFileName(fuImportFile.FileName);
                    string filePath     = Path.Combine(Settings.GetSetting(Settings.Keys.API_TEMP_UPLOAD_FOLDER), filename);
                    string fullFilePath = filePath;
                    if (!fullFilePath.Contains(@":/") && !fullFilePath.Contains(@":\"))
                    {
                        fullFilePath = Server.MapPath(filePath);
                    }

                    //Save that file in temp folder
                    fuImportFile.SaveAs(fullFilePath);

                    ReadCSVFile(fullFilePath);

                    phErrors.Visible       = true;
                    phAppUsersList.Visible = true;
                    phImportResult.Visible = false;
                }
                else
                {
                    Master.MessageCenter.DisplayErrorMessage(AppUsersStrings.GetText(@"ImportFileWrongFormat"));
                    return;
                }
            }
            else
            {
                lblErrors.Text         = AppUsersStrings.GetText(@"MessageFileNotSelected");
                phErrors.Visible       = true;
                phAppUsersList.Visible = false;
                phImportResult.Visible = false;
            }
        }
Beispiel #9
0
 protected void Page_PreRender(object sender, EventArgs e)
 {
     Master.PageTitleHtml = string.Format(AppUsersStrings.GetText(@"DeleteAppUserPageTitle"), AppUserName);
     Master.ActiveMenu    = "AppUsers";
 }
Beispiel #10
0
        private void ReadCSVFile(string filePath)
        {
            using (FileStream fs = new FileStream(filePath, FileMode.Open))
            {
                using (CsvReader csv = new CsvReader(fs))
                {
                    string[] _values = null;

                    CsvDataTable = new DataTable();
                    CsvDataTable.Columns.Add(new DataColumn("Line", typeof(int)));
                    CsvDataTable.Columns.Add(new DataColumn("Email", typeof(string)));
                    CsvDataTable.Columns.Add(new DataColumn("Password", typeof(string)));
                    CsvDataTable.Columns.Add(new DataColumn("FirstName", typeof(string)));
                    CsvDataTable.Columns.Add(new DataColumn("LastName", typeof(string)));
                    CsvDataTable.Columns.Add(new DataColumn("IsLocked", typeof(string)));
                    CsvDataTable.Columns.Add(new DataColumn("Phone", typeof(string)));
                    CsvDataTable.Columns.Add(new DataColumn("Comments", typeof(string)));

                    bool bErrors             = false;
                    int  line                = -1;
                    int  numAppUsersToImport = 0;
                    _values = csv.ReadRow();
                    while (_values != null)
                    {
                        if (++line == 0)
                        {
                            _values = csv.ReadRow();
                            continue;
                        }

                        DataRow DR       = CsvDataTable.NewRow();
                        string  comments = "";

                        try
                        {
                            DR["Line"]      = line;
                            DR["Email"]     = _values[0] == "" ? "" : _values[0].Trim();
                            DR["Password"]  = _values[1] == "" ? "" : _values[1].Trim();
                            DR["FirstName"] = _values[2] == "" ? "" : _values[2].Trim();
                            DR["LastName"]  = _values[3] == "" ? "" : _values[3].Trim();
                            DR["IsLocked"]  = _values[4] == "" ? "" : _values[4].Trim();
                            DR["Phone"]     = _values[5] == "" ? "" : _values[5].Trim('"');

                            //Email must be unique
                            if (core.DAL.AppUser.FetchByEmail(DR["Email"].ToString()) != null)
                            {
                                if (comments != "")
                                {
                                    comments += "<br />";
                                }
                                comments += AppUsersStrings.GetText(@"MessageEmailAlreadyExists");
                            }
                        }
                        catch (Exception e)
                        {
                            if (comments != "")
                            {
                                comments += "<br />";
                            }
                            comments += AppUsersStrings.GetText(@"MessageLineParsingError") + ": " + e.Message;
                        }

                        if (comments != "")
                        {
                            bErrors   = true;
                            comments += "<br />" + AppUsersStrings.GetText(@"MessageAppUsersWillNotImported");
                        }
                        else
                        {
                            numAppUsersToImport++;
                        }

                        DR["Comments"] = comments;
                        CsvDataTable.Rows.Add(DR);

                        _values = csv.ReadRow();
                    }

                    if (bErrors)
                    {
                        lblErrors.Text = AppUsersStrings.GetText(@"ImportErrorsLabel");;
                    }
                    else
                    {
                        lblErrors.Text = AppUsersStrings.GetText(@"ImportNoErrorsLabel");;
                    }

                    dgAppUsers.DataSource = CsvDataTable;
                    dgAppUsers.DataBind();
                    lblTotal.Text         = CsvDataTable.Rows.Count.ToString();
                    lblTotalToImport.Text = numAppUsersToImport.ToString();
                    btnImport.Enabled     = numAppUsersToImport == 0 ? false : true;
                }
            }
        }
Beispiel #11
0
 protected void Page_PreRender(object sender, EventArgs e)
 {
     Master.PageTitleHtml = AppUsersStrings.GetText(@"ImportAppUsersPageTitle");
     Master.ActiveMenu    = "ImportAppUsers";
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            string SupplierEmail = null;
            bool   EmailChanged  = false;

            AppSupplier supplier = null;

            if (IsNewMode)
            {
                Membership.UserCreateResults results = Membership.CreateSupplier(txtEmail.Text, txtPassword.Text.Trim(), Convert.ToInt64(ddlCity.SelectedValue), out supplier);
                switch (results)
                {
                default:
                case Membership.UserCreateResults.UnknownError:
                    Master.MessageCenter.DisplayErrorMessage(SuppliersStrings.GetText(@"MessageCreateFailedUnknown"));
                    return;

                case Membership.UserCreateResults.AlreadyExists:
                    Master.MessageCenter.DisplayErrorMessage(SuppliersStrings.GetText(@"MessageCreateFailedAlreadyExists"));
                    return;

                case Membership.UserCreateResults.InvalidEmailAddress:
                    Master.MessageCenter.DisplayErrorMessage(SuppliersStrings.GetText(@"MessageCreateFailedEmailAddressInvalid"));
                    return;

                case Membership.UserCreateResults.Success:
                    break;
                }
                SupplierId    = supplier.SupplierId;
                SupplierEmail = supplier.Email;
                //supplier.OrderDisplay = OrderDisplay.GetLastOrder() + 1;
            }
            else
            {
                supplier      = core.DAL.AppSupplier.FetchByID(SupplierId);
                SupplierEmail = supplier.Email;
            }
            supplier.BusinessName = txtBusinessName.Text;

            if (ddlIsProduct.SelectedValue == "prod")
            {
                supplier.IsProduct = true;
                supplier.IsService = false;
            }
            else
            {
                supplier.IsProduct = false;
                supplier.IsService = true;
            }
            //supplier.IsProduct = chkIsProduct.Checked;
            //supplier.IsService = chkIsService.Checked;
            supplier.IsPremium    = chkIsPremium.Checked;
            supplier.IsLocked     = chkIsLocked.Checked;
            supplier.ContactName  = txtContactName.Text;
            supplier.ContactPhone = txtContactPhone.Text;
            supplier.Phone        = txtPhone.Text;
            supplier.CityId       = Convert.ToInt64(ddlCity.SelectedValue);
            supplier.Street       = txtStreet.Text;
            supplier.HouseNum     = txtHouseNum.Text;
            try
            {
                string city = ddlCity.SelectedItem.Text;
                //var address = (city != "" ? city + " " : "") +" "+ (txtStreet.Text != "" ? txtStreet.Text+" " : "") + (txtHouseNum.Text != "" ? txtHouseNum.Text : "");
                var locationService = new GoogleLocationService();
                var point           = (city.Trim() != "" ? locationService.GetLatLongFromAddress(city) : new MapPoint());
                supplier.AddressLocation = new Geometry.Point(point.Latitude, point.Longitude);
            }
            catch (Exception) {
                supplier.AddressLocation = new Geometry.Point(0, 0);
            }
            supplier.HouseNum = txtHouseNum.Text;

            supplier.Precent     = txtPrecent.Text != "" ?Convert.ToInt32(txtPrecent.Text):0;
            supplier.SumPerMonth = txtSumPerMonth.Text != "" ? Convert.ToInt32(txtSumPerMonth.Text) : 0;
            //supplier.StatusJoinBid = chkIsStatusJoinBid.Checked;
            //supplier.AllowChangeStatusJoinBid = chkAllowChangeStatusJoinBid.Checked;
            //supplier.MaxWinningsNum =txtMaxWinningsNum.Text != "" ? Convert.ToInt32(txtMaxWinningsNum.Text) : 0;
            supplier.MastercardCode = txtMastercardCode.Text;
            supplier.Save();

            if (IsNewMode)
            {
                SupplierId = supplier.SupplierId;
                //if (chkIsStatusJoinBid.Checked == false)//handel
                //{
                //    (new Query(SupplierProduct.TableSchema).Where(SupplierProduct.Columns.SupplierId, SupplierId).Delete()).Execute();
                //    ProductCollection pcol = ProductCollection.FetchByQuery(new Query(Product.TableSchema).Where(Product.Columns.IsDeleted, false));
                //    foreach (Product item in pcol)
                //    {
                //        SupplierProduct sp = new SupplierProduct();
                //        sp.SupplierId = SupplierId;
                //        sp.ProductId = item.ProductId;
                //        sp.Gift = "";
                //        sp.Save();
                //    }
                //}
            }
            //if (chkIsService.Checked)
            if (ddlIsProduct.SelectedValue != "prod")
            {
                foreach (ListItem item in ddlServices.Items)
                {
                    if (item.Selected)
                    {
                        SupplierService supplierService = SupplierService.FetchByID(Convert.ToInt64(item.Value), SupplierId);
                        if (supplierService == null)
                        {
                            supplierService            = new SupplierService();
                            supplierService.SupplierId = SupplierId;
                            supplierService.ServiceId  = Convert.ToInt64(item.Value);
                            supplierService.Save();
                        }
                    }
                    else
                    {
                        SupplierService.Delete(Convert.ToInt64(item.Value), SupplierId);
                    }
                }
            }
            else
            {
                SupplierController.DeleteAllSupplierServices(SupplierId);
            }

            if (supplier.Email != txtEmail.Text.Trim().NormalizeEmail())
            {
                if (AppSupplier.FetchByEmail(txtEmail.Text.Trim().NormalizeEmail()) != null)
                {
                    Master.MessageCenter.DisplayWarningMessage(AppUsersStrings.GetText(@"MessageEmailChangeFailed"));
                }
                else
                {
                    supplier.Email          = txtEmail.Text.Trim().NormalizeEmail();
                    supplier.UniqueIdString = supplier.Email;//email.NormalizeEmail();
                    SupplierEmail           = supplier.Email;
                    EmailChanged            = true;
                }
            }

            SupplierEmail = supplier.Email;
            supplier.Save();

            if (txtPassword.Text.Length > 0)
            {
                if (txtConfirmPassword.Text != txtPassword.Text)
                {
                    Master.MessageCenter.DisplayErrorMessage(SuppliersStrings.GetText(@"SupplierNewPasswordConfirmInvalid"));
                    return;
                }
                Membership.UserPasswordChangeResults results;
                results = Membership.ChangeSupplierPassword(supplier.Email, txtPassword.Text);
                switch (results)
                {
                default:
                    Master.MessageCenter.DisplayWarningMessage(SuppliersStrings.GetText(@"MessagePasswordChangeFailedUnknown"));
                    break;

                case Membership.UserPasswordChangeResults.PasswordDoNotMatch:
                    Master.MessageCenter.DisplayWarningMessage(SuppliersStrings.GetText(@"MessagePasswordChangeBadOldPassword"));
                    break;

                case Membership.UserPasswordChangeResults.Success:
                    break;
                }
            }

            if (IsNewMode)
            {
                string successMessage = SuppliersStrings.GetText(@"MessageSupplierCreated");
                string url            = @"EditSupplier.aspx?Email=" + SupplierEmail + "&SupplierId=" + supplier.SupplierId;
                url += @"&message-success=" + Server.UrlEncode(successMessage);
                Response.Redirect(url, true);
            }
            else
            {
                string successMessage = SuppliersStrings.GetText(@"MessageSupplierSaved");
                if (EmailChanged)
                {
                    string url = @"EditSupplier.aspx?message-success=" + Server.UrlEncode(successMessage) + "&SupplierId=" + supplier.SupplierId;
                    if (SupplierId != supplier.SupplierId)
                    {
                        url += @"&Email=" + SupplierEmail;
                    }
                    Response.Redirect(url, true);
                }
                else
                {
                    Master.MessageCenter.DisplaySuccessMessage(successMessage);
                    LoadView();
                }
            }
        }
 protected void Page_PreRender(object sender, EventArgs e)
 {
     Master.PageTitle  = AppUsersStrings.GetText(@"AppUsersPageTitle");
     Master.ActiveMenu = "AppUsers";
     Master.AddClientScriptInclude(@"dgDateManager.js");
 }
Beispiel #14
0
        protected void btnExportForCRM_Click(object sender, EventArgs e)
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"CustomerId"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"FirstName"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"LastName"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"Email"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"Phone"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"Address"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"CityName"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(AppUsersStrings.GetText(@"CreateDate"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"BidId"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"Products"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"Price"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(BidString.GetText(@"OrderDate"), typeof(string)));
            dt.Columns.Add(new System.Data.DataColumn(OrdersStrings.GetText(@"ActionType"), typeof(string)));



            DateTime from = new DateTime(), to = new DateTime();

            DateTime.TryParse(dpSearchCreateDateFrom.Value.ToString(), out from);
            DateTime.TryParse(dpSearchCreateDateTo.Value.ToString(), out to);
            Int64 _BidId = -1;

            if (txtBidNumber.Text != "")
            {
                Int64.TryParse(txtBidNumber.Text, out _BidId);
            }
            List <BidUI> app_users = BidController.GetAllBids(filterSearch, from, to, txtSearchPhone.Text, txtCustomerId.Text, _BidId, txtCityName.Text);

            foreach (BidUI Bid in app_users)
            {
                int i = 0;
                System.Data.DataRow row = dt.NewRow();
                var appUser             = AppUser.FetchByID(Bid.CustomerId);
                row[i++] = Bid.CustomerId;
                row[i++] = Bid.CustomerType == CustomerType.Temp ? BidString.GetText("Temp") : appUser.FirstName;
                row[i++] = Bid.CustomerType == CustomerType.Temp ? BidString.GetText("Temp") : appUser.LastName;
                row[i++] = Bid.CustomerType == CustomerType.Temp ? BidString.GetText("Temp") : appUser.Email;
                row[i++] = Bid.CustomerType == CustomerType.Temp ? BidString.GetText("Temp") : "=\"" + appUser.Phone + "\"";
                row[i++] = Bid.CustomerType == CustomerType.Temp ? BidString.GetText("Temp") : appUser.Street + " " + appUser.HouseNum;
                row[i++] = Bid.City;
                row[i++] = Bid.CustomerType == CustomerType.Temp ? BidString.GetText("Temp") : appUser.CreateDate.ToString();
                row[i++] = Bid.BidId;
                row[i++] = Bid.Products;
                row[i++] = Bid.Price;
                row[i++] = Bid.OrderDate;
                row[i++] = "רכישה";
                dt.Rows.Add(row);
            }

            SpreadsheetWriter ex = SpreadsheetWriter.FromDataTable(dt, false, true);

            Response.Clear();
            Response.AddHeader(@"content-disposition", @"attachment;filename=BidsExportForCRM_" + DateTime.UtcNow.ToString(@"yyyy_MM_dd_HH_mm_ss") + "." + ex.FileExtension);
            Response.Charset         = @"UTF-8";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = ex.FileContentType;
            Response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());
            Response.Write(ex.ToString());
            Response.End();
        }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
            return;
        }

        string Email          = null;
        bool   EmailChanged   = false;
        string AdCompanyEmail = null;

        AdCompany company = null;

        if (IsNewMode)
        {
            Membership.UserCreateResults results = Membership.CreateAdCompany(txtEmail.Text, out company);
            switch (results)
            {
            default:
            case Membership.UserCreateResults.UnknownError:
                Master.MessageCenter.DisplayErrorMessage(SuppliersStrings.GetText(@"MessageCreateFailedUnknown"));
                return;

            case Membership.UserCreateResults.AlreadyExists:
                Master.MessageCenter.DisplayErrorMessage(SuppliersStrings.GetText(@"MessageCreateFailedAlreadyExists"));
                return;

            case Membership.UserCreateResults.InvalidEmailAddress:
                Master.MessageCenter.DisplayErrorMessage(SuppliersStrings.GetText(@"MessageCreateFailedEmailAddressInvalid"));
                return;

            case Membership.UserCreateResults.Success:
                break;
            }
            CompanyId           = company.CompanyId;
            company.CreatedDate = DateTime.Now;
            AdCompanyEmail      = company.Email;
        }
        else
        {
            company        = AdCompany.FetchByID(CompanyId);
            AdCompanyEmail = company.Email;
        }
        company.BusinessName = txtBusinessName.Text;
        company.ContactName  = txtContactName.Text;
        company.ContactPhone = txtContactPhone.Text;
        company.Phone        = txtPhone.Text;
        company.Description  = txtDescription.Text;
        company.Save();

        if (IsNewMode)
        {
            CompanyId = company.CompanyId;
        }

        if (company.Email != txtEmail.Text.Trim().NormalizeEmail())
        {
            if (AdCompany.FetchByEmail(txtEmail.Text.Trim().NormalizeEmail()) != null)
            {
                Master.MessageCenter.DisplayWarningMessage(AppUsersStrings.GetText(@"MessageEmailChangeFailed"));
            }
            else
            {
                company.Email = txtEmail.Text.Trim().NormalizeEmail();
                EmailChanged  = true;
            }
        }

        AdCompanyEmail = company.Email;
        company.Save();

        if (IsNewMode)
        {
            string successMessage = AdvertisementsStrings.GetText(@"MessageCompanyCreated");
            string url            = @"EditAdCompany.aspx?Email=" + AdCompanyEmail + "&CompanyId=" + company.CompanyId;
            url += @"&message-success=" + Server.UrlEncode(successMessage);
            Response.Redirect(url, true);
        }
        else
        {
            string successMessage = SuppliersStrings.GetText(@"MessageSupplierSaved");
            if (EmailChanged)
            {
                string url = @"EditAdCompany.aspx?message-success=" + Server.UrlEncode(successMessage) + "&CompanyId=" + company.CompanyId;
                if (CompanyId != company.CompanyId)
                {
                    url += @"&Email=" + AdCompanyEmail;
                }
                Response.Redirect(url, true);
            }
            else
            {
                Master.MessageCenter.DisplaySuccessMessage(successMessage);
                LoadView();
            }
        }
    }
Beispiel #16
0
 protected void Page_Init(object sender, EventArgs e)
 {
     Master.AddButtonNew(AppUsersStrings.GetText(@"NewAppUserButton"), @"EditAppUser.aspx?New=yes", new string[] { Permissions.PermissionKeys.sys_perm });
 }
Beispiel #17
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            string AppUserEmail = null;
            bool   EmailChanged = false;

            AppUser app_user = null;

            if (IsNewMode)
            {
                AppMembership.AppUserCreateResults results = AppMembership.CreateAppUser(txtEmail.Text, txtPassword.Text.Trim(), @"", out app_user);
                switch (results)
                {
                default:
                case AppMembership.AppUserCreateResults.UnknownError:
                    Master.MessageCenter.DisplayErrorMessage(AppUsersStrings.GetText(@"MessageCreateFailedUnknown"));
                    return;

                case AppMembership.AppUserCreateResults.AlreadyExists:
                    Master.MessageCenter.DisplayErrorMessage(AppUsersStrings.GetText(@"MessageCreateFailedAlreadyExists"));
                    return;

                case AppMembership.AppUserCreateResults.InvalidEmailAddress:
                    Master.MessageCenter.DisplayErrorMessage(AppUsersStrings.GetText(@"MessageCreateFailedEmailAddressInvalid"));
                    return;

                case AppMembership.AppUserCreateResults.Success:
                    break;
                }
                AppUserId    = app_user.AppUserId;
                AppUserEmail = app_user.Email;
                //app_user.OrderDisplay = OrderDisplay.GetLastOrder() + 1;
            }
            else
            {
                app_user     = core.DAL.AppUser.FetchByID(AppUserId);
                AppUserEmail = app_user.Email;
            }
            app_user.CityId          = Convert.ToInt64(ddlCity.SelectedValue);
            app_user.IsLocked        = chkIsLocked.Checked;
            app_user.FirstName       = txtFirstName.Text;
            app_user.LastName        = txtlastName.Text;
            app_user.Phone           = txtPhone.Text;
            app_user.Street          = txtStreet.Text;
            app_user.CityId          = Int64.Parse(ddlCity.SelectedValue);
            app_user.ApartmentNumber = txtAptNum.Text;
            app_user.HouseNum        = txtHouseNum.Text;
            app_user.Floor           = txtFloor.Text;

            try
            {
                string city = ddlCity.SelectedItem.Text;
                //var address = (city != "" ? city + " " : "") + " " + (txtStreet.Text != "" ? txtStreet.Text + " " : "") + (txtHouseNum.Text != "" ? txtHouseNum.Text : "");
                var locationService = new GoogleLocationService();
                var point           = (city.Trim() != "" ? locationService.GetLatLongFromAddress(city) : new MapPoint());
                app_user.AddressLocation = new Geometry.Point(point.Latitude, point.Longitude);
            }
            catch
            {
                Master.MessageCenter.DisplayErrorMessage(AppUsersStrings.GetText(@"MessageAddressInvalid"));
                return;
            }
            app_user.Save();
            if (IsNewMode)
            {
                AppUserId = app_user.AppUserId;
            }

            if (app_user.Email != txtEmail.Text.Trim().NormalizeEmail())
            {
                if (AppUser.FetchByEmail(txtEmail.Text.Trim().NormalizeEmail()) != null)
                {
                    Master.MessageCenter.DisplayWarningMessage(AppUsersStrings.GetText(@"MessageEmailChangeFailed"));
                }
                else
                {
                    app_user.Email          = txtEmail.Text.Trim().NormalizeEmail();
                    app_user.UniqueIdString = app_user.Email;
                    AppUserEmail            = app_user.Email;
                    EmailChanged            = true;
                }
            }

            AppUserEmail = app_user.Email;

            app_user.Save();

            if (txtPassword.Text.Length > 0)
            {
                AppMembership.AppUserPasswordChangeResults results;
                //if (AppUserId == SessionHelper.UserId())
                //{
                //    results = AppMembership.ChangeAppUserPassword(app_user.Email, txtCurrentPassword.Text, txtPassword.Text);
                //}
                //else
                //{
                results = AppMembership.ChangeAppUserPassword(app_user.Email, txtPassword.Text);
                //}
                switch (results)
                {
                default:
                    Master.MessageCenter.DisplayWarningMessage(AppUsersStrings.GetText(@"MessagePasswordChangeFailedUnknown"));
                    break;

                case AppMembership.AppUserPasswordChangeResults.PasswordDoNotMatch:
                    Master.MessageCenter.DisplayWarningMessage(AppUsersStrings.GetText(@"MessagePasswordChangeBadOldPassword"));
                    break;

                case AppMembership.AppUserPasswordChangeResults.Success:
                    break;
                }
            }

            if (IsNewMode)
            {
                string successMessage = AppUsersStrings.GetText(@"MessageAppUserCreated");
                string url            = @"EditAppUser.aspx?Email=" + AppUserEmail;
                url += @"&message-success=" + Server.UrlEncode(successMessage);
                Response.Redirect(url, true);
            }
            else
            {
                string successMessage = AppUsersStrings.GetText(@"MessageAppUserSaved");
                if (EmailChanged)
                {
                    string url = @"EditAppUser.aspx?message-success=" + Server.UrlEncode(successMessage);
                    if (AppUserId != SessionHelper.UserId())
                    {
                        url += @"&Email=" + AppUserEmail;
                    }
                    Response.Redirect(url, true);
                }
                else
                {
                    Master.MessageCenter.DisplaySuccessMessage(successMessage);
                    LoadView();
                }
            }
        }