Ejemplo n.º 1
0
        private void FillList()
        {
            tableDialogs.TableModel.Rows.Clear();

            CategoryTableAdapter kategorieTableAdapter = new CategoryTableAdapter(dataBase);
            CategoryDataSet      ds = new CategoryDataSet();

            kategorieTableAdapter.Fill(ds.Category);

            // Zuerst der Standard-Dialog
            string[] newRow = new string[2];
            newRow[0] = "<" + StringTable.Default + ">";
            newRow[1] = HasDialog(0) ? StringTable.Yes : StringTable.No;
            XPTable.Models.Row newTableRow = new XPTable.Models.Row(newRow);
            newTableRow.Tag = null;
            tableDialogs.TableModel.Rows.Add(newTableRow);

            foreach (CategoryDataSet.CategoryRow row in ds.Category.Rows)
            {
                newRow[0]       = row.Name;
                newRow[1]       = HasDialog(row.CategoryID) ? StringTable.Yes : StringTable.No;
                newTableRow     = new XPTable.Models.Row(newRow);
                newTableRow.Tag = row;
                tableDialogs.TableModel.Rows.Add(newTableRow);
            }
        }
Ejemplo n.º 2
0
        private void CategoryDetailForm_Load(object sender, EventArgs e)
        {
            try
            {
                LocalizedCategoryNameTableAdapter localizedCategoryNameAdapter = new LocalizedCategoryNameTableAdapter();
                localizedCategoryNameAdapter.Fill(this.categoryDetailDataSet.LocalizedCategoryName, categoryId, cultureName);

                if (categoryId > 0)
                {
                    CategoryTableAdapter categoryAdapter = new CategoryTableAdapter();
                    categoryAdapter.Fill(this.categoryDetailDataSet.Category, categoryId);
                }

                byte[] image = this.categoryDetailDataSet.Category.Rows[0]["Image"] as byte[];
                if (image != null)
                {
                    this.pictureBoxImage.Image = ImageEngine.Resize(ImageEngine.FromArray(image), this.pictureBoxImage.Size);
                }

                EnableButtons();
            }
            catch (Exception ex)
            {
                ReportError(ex.Message.ToString());
                this.DialogResult = DialogResult.Abort;
                this.Close();
            }
        }
Ejemplo n.º 3
0
    public void DataViewDemo()
    {
        DataSet1.CategoryDataTable Category = new DataSet1.CategoryDataTable();
        CategoryTableAdapter       catAdap  = new CategoryTableAdapter();

        catAdap.Fill(Category);

        DataSet1.ProductsDataTable Products = new DataSet1.ProductsDataTable();
        ProductsTableAdapter       prodAdap = new ProductsTableAdapter();

        prodAdap.Fill(Products);

        var result = from item in Products
                     select item;
        DataView view = result.AsDataView();

        view.Sort            = "ProductName desc";
        view.RowFilter       = "CategoryID = 65985";
        GridView7.DataSource = view;
        GridView7.DataBind();
        DataSet1.ProductsRow        row    = null;
        List <DataSet1.ProductsRow> myList = new List <DataSet1.ProductsRow>();

        foreach (DataRowView item in view)
        {
            row = (DataSet1.ProductsRow)item.Row;
            myList.Add(row);
        }
        GridView8.DataSource = myList;
        GridView8.DataBind();
    }
Ejemplo n.º 4
0
        public int GetIdByName(string name, bool createIfNew)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(0);
            }

            Category category = GetByName(name);

            if (category != null)
            {
                return(category.CategoryID);
            }
            else
            {
                // Nicht vorhanden, also neue Kategorie anlegen
                CategoryTableAdapter cta = new CategoryTableAdapter(dataBase);
                CategoryDataSet.CategoryDataTable cdt = cta.GetData();
                cdt.AddCategoryRow(name, cdt.Rows.Count);
                cta.Update(cdt);

                int categoryid = (int)(decimal)dataBase.ExecuteScalar("SELECT @@IDENTITY");

                dataBase.UpdateCategories();

                return(categoryid);
            }
        }
Ejemplo n.º 5
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            FormName formName = new FormName();

            formName.Text          = StringTable.AddNewCategory;
            formName.NameValue     = "";
            formName.AllowEmpty    = false;
            formName.ValidateName += delegate(object sender1, ValidateNameEventArgs e1)
            {
                if (dataBase.AllCategories.Names.Contains(e1.Name) && e1.Name != e1.OriginalName)
                {
                    MessageBox.Show(string.Format(StringTable.CategoryAlreadyExists, e1.Name), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    e1.Cancel = true;
                }
            };
            if (formName.ShowDialog(this) == DialogResult.OK)
            {
                CategoryTableAdapter cta = new CategoryTableAdapter(dataBase);
                CategoryDataSet.CategoryDataTable cdt = cta.GetData();
                cdt.AddCategoryRow(formName.NameValue, listBoxCategories.Items.Count + 1);
                cta.Update(cdt);

                FillList();
            }

            UpdateWindowState();
        }
Ejemplo n.º 6
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = StringTable.FilterHitbase;
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                DataBase dbImport = new DataBase();
                dbImport.Open(openFileDialog.FileName);

                CategoryTableAdapter cta = new CategoryTableAdapter(dataBase);
                CategoryDataSet.CategoryDataTable cdt = cta.GetData();

                int count = listBoxCategories.Items.Count + 1;
                foreach (Category category in dbImport.AllCategories)
                {
                    if (dataBase.GetIdByCategory(category.Name) < 0)
                    {
                        cdt.AddCategoryRow(category.Name, count++);
                    }
                }

                cta.Update(cdt);

                dbImport.Close();

                FillList();
                UpdateWindowState();
            }
        }
Ejemplo n.º 7
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            string categoryName = txtCategory.Text.Trim();

            if (string.IsNullOrEmpty(categoryName))
            {
                txtCategoryValidator.ErrorMessage = "Category cannot be blank";
                return;
            }

            CategoryTableAdapter categoryAdapter = new CategoryTableAdapter();

            int categoryMatches = (int)categoryAdapter.ValidateCategoryName(categoryName);

            if (categoryMatches != 0)
            {
                ErrorMessage = "There's already a category created with that name";
                return;
            }

            categoryAdapter.Insert(StationId, null, categoryName, -1);

            InfoMessage = "Category created";

            Response.Redirect("~/admin/CategoryList.aspx");
        }
Ejemplo n.º 8
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (listBoxCategories.SelectedItem == null)
            {
                return;
            }

            ListBoxItem item = (ListBoxItem)listBoxCategories.SelectedItem;

            FormName formName = new FormName();

            formName.Text      = StringTable.EditCategory;
            formName.NameValue = item.Category.Name;
            if (formName.ShowDialog(this) == DialogResult.OK)
            {
                int oldId = dataBase.GetIdByCategory(item.Category.Name);

                CategoryTableAdapter cta = new CategoryTableAdapter(dataBase);
                CategoryDataSet.CategoryDataTable cdt = cta.GetDataById(item.Category.CategoryID);
                cdt[0].Name = formName.NameValue;
                cta.Update(cdt);

                listBoxCategories.Items[listBoxCategories.SelectedIndex] = new ListBoxItem(cdt[0]);

                UpdateSoundfiles(oldId, item.Category.Name, formName.NameValue, false);
            }

            UpdateWindowState();
        }
        void deleteButton_Click(object sender, EventArgs e)
        {
            categoryId = Int32.Parse(idHidden.Value);

            CategoryTableAdapter categoryAdapter = new CategoryTableAdapter();

            try
            {
                int parentCategoryId = category.ParentCategoryId;
                categoryAdapter.Delete(categoryId);

                InfoMessage = "Category Deleted";

                if (parentCategoryId > 0)
                {
                    Response.Redirect("~/admin/CategoryEdit.aspx?id=" + parentCategoryId);
                }
                else
                {
                    Response.Redirect("~/admin/CategoryList.aspx");
                }
            }
            catch (SqlException ex)
            {
                if (ex.Number == 547)
                {
                    ErrorMessage = "Category cannot be deleted because it is assigned to an Advertiser";
                }
                else
                {
                    throw ex;
                }
            }
        }
Ejemplo n.º 10
0
        private void FormProduct_Load(object sender, EventArgs e)
        {
            string        conn_str = "Server=.;Database=MiniMart;Integrated Security=true;";
            SqlConnection conn     = new SqlConnection(conn_str);

            cate_adapter            = new CategoryTableAdapter();
            cate_adapter.Connection = conn;
            cate_adapter.Fill(invent.Category);

            unit_adapter            = new UnitTypeTableAdapter();
            unit_adapter.Connection = conn;
            unit_adapter.Fill(invent.UnitType);

            pro_adapter            = new ProductTableAdapter();
            pro_adapter.Connection = conn;
            pro_adapter.Fill(invent.Product);

            //bind to controls
            cboCategory.DisplayMember = invent.Category.NameColumn.ColumnName;
            cboCategory.ValueMember   = invent.Category.IDColumn.ColumnName;
            cboCategory.DataSource    = invent.Category;

            cboUnitType.DisplayMember = invent.UnitType.NameColumn.ColumnName;
            cboUnitType.ValueMember   = invent.UnitType.IDColumn.ColumnName;
            cboUnitType.DataSource    = invent.UnitType;

            dataGridView1.DataSource = invent.Product;
            (dataGridView1.Columns[invent.Product.ImageColumn.ColumnName]  as DataGridViewImageColumn).ImageLayout = DataGridViewImageCellLayout.Zoom;

            lblTotal.Text = "Total: " + invent.Product.Rows.Count.ToString();
        }
Ejemplo n.º 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DataSet1.CategoryDataTable Category = new DataSet1.CategoryDataTable();
        CategoryTableAdapter       catAdap  = new CategoryTableAdapter();

        DataSet1.ProductsDataTable Products = new DataSet1.ProductsDataTable();
        ProductsTableAdapter       prodAdap = new ProductsTableAdapter();

        catAdap.Fill(Category);
        prodAdap.Fill(Products);

        var result = from item in Products
                     select item;

        DataTable queriedProducts = result.CopyToDataTable <DataSet1.ProductsRow>();

        queriedProducts.TableName = "queriedProducts";
        DataSet1 ds = new DataSet1();

        ds.Tables.Add(queriedProducts);
        //DataView view = result.AsDataView<DataSet1.ProductsRow>();
        //view.RowFilter = "CategoryID = 65985";
        GridView1.DataSource = ds.Tables["queriedProducts"];
        GridView1.DataBind();
    }
Ejemplo n.º 12
0
        private void btnCatsFromLocal_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            string connectionPrefix = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
            string client           = new Uri(dmc.origUrl).Host;
            string filename         = client + ".mdb";
            string app_data         = Path.GetDirectoryName(Application.ExecutablePath) + @"\App_data\";
            string dest             = app_data + filename;

            if (!File.Exists(dest))
            {
                MessageBox.Show("Cannot find data file");
                return;
            }
            string connection = connectionPrefix + dest;

            using (CategoryTableAdapter catsda = new CategoryTableAdapter())
            {
                catsda.SetConnection(new OleDbConnection(connection));
                LocalCats.CategoryDataTable cats = new LocalCats.CategoryDataTable();
                catsda.Fill(cats);
                catsGrid.DataSource = cats;
            }
            Cursor.Current = Cursors.Default;
            return;
        }
        // this class is used to create objects from the data in the database, using the dataset
        private DatabaseController()
        {
            this.DataSet                     = new KantoorInrichtingDataSet();
            this.TableAdapterManager         = new KantoorInrichtingDataSetTableAdapters.TableAdapterManager();
            this.CategoryTableAdapter        = new KantoorInrichtingDataSetTableAdapters.categoryTableAdapter();
            this.ProductTableAdapter         = new KantoorInrichtingDataSetTableAdapters.productTableAdapter();
            this.PlacementTableAdapter       = new KantoorInrichtingDataSetTableAdapters.placementTableAdapter();
            this.RoleTableAdapter            = new KantoorInrichtingDataSetTableAdapters.roleTableAdapter();
            this.SpaceTableAdapter           = new KantoorInrichtingDataSetTableAdapters.spaceTableAdapter();
            this.StaticPlacementTableAdapter = new KantoorInrichtingDataSetTableAdapters.static_placementTableAdapter();
            this.StaticProductTableAdapter   = new KantoorInrichtingDataSetTableAdapters.static_productTableAdapter();
            this.UserTableAdapter            = new KantoorInrichtingDataSetTableAdapters.userTableAdapter();

            CategoryTableAdapter.Fill(DataSet.category);
            ProductTableAdapter.Fill(DataSet.product);
            PlacementTableAdapter.Fill(DataSet.placement);
            RoleTableAdapter.Fill(DataSet.role);
            SpaceTableAdapter.Fill(DataSet.space);
            StaticPlacementTableAdapter.Fill(DataSet.static_placement);
            StaticProductTableAdapter.Fill(DataSet.static_product);
            UserTableAdapter.Fill(DataSet.user);


            GetCategories_FromDatabase();
            GetProducts_FromDatabase();
            GetStaticProducts_FromDatabase();
            GetSpaces_FromDatabase();
        }
Ejemplo n.º 14
0
        public void AddNew(string category)
        {
            // Nicht vorhanden, also neue Kategorie anlegen
            CategoryTableAdapter cta = new CategoryTableAdapter(dataBase);

            CategoryDataSet.CategoryDataTable cdt = cta.GetData();
            cdt.AddCategoryRow(category, GetNextOrder());
            cta.Update(cdt);

            dataBase.UpdateCategories();
        }
Ejemplo n.º 15
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            CategoryTableAdapter categoryAdapter = new CategoryTableAdapter();

            DollarSaverDB.CategoryDataTable categories = categoryAdapter.GetPrimaryCategoriesByStation(StationId);

            categoryGrid.DataSource = categories.Rows;
            categoryGrid.DataBind();
        }
Ejemplo n.º 16
0
        private void FormSaveDialog_Load(object sender, EventArgs e)
        {
            CategoryTableAdapter kategorieTableAdapter = new CategoryTableAdapter(dataBase);
            CategoryDataSet      ds = new CategoryDataSet();

            kategorieTableAdapter.Fill(ds.Category);
            foreach (CategoryDataSet.CategoryRow row in ds.Category.Rows)
            {
                listBoxCategories.Items.Add(new ListBoxItem(row.CategoryID, row.Name));
            }
        }
 public ExperlogixRepository()
 {
     _seriesAdapter = new SeriesTableAdapter();
     _modelAdapter = new ModelTableAdapter();
     _categoryAdapter = new CategoryTableAdapter();
     _listAdapter = new ListTableAdapter();
     _lookupAdapter = new LookupTableAdapter();
     _ruleAdapter = new RuleTableAdapter();
     _attributeAdapter = new CategoryAttributeTableAdapter();
     _formulaAdapter = new FormulaTableAdapter();
     _attributeLookupAdapter = new CategoryAttLookupTableAdapter();
 }
Ejemplo n.º 18
0
 private void Form1_Load(object sender, EventArgs e)
 {
     BalanceTableAdapter.Fill(stockDataSet.Остатки);
     TaxingTableAdapter.Fill(stockDataSet.Таксировка);
     TaxTableAdapter.Fill(stockDataSet.Налоги);
     BankTableAdapter.Fill(stockDataSet.Банк);
     OrganizationTableAdapter.Fill(stockDataSet.Организация);
     InvoiceTableAdapter.Fill(stockDataSet.Накладные);
     MoveProductTableAdapter.Fill(stockDataSet.Движение_товара);
     DivisionsTableAdapter.Fill(stockDataSet.Подразделения);
     ProductTableAdapter.Fill(stockDataSet.Товар);
     CategoryTableAdapter.Fill(stockDataSet.Категории_товара);
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Aktualisiert die Order aus der Liste in die Datenbank.
        /// </summary>
        private void SetOrderByList()
        {
            int index = 1;

            foreach (ListBoxItem item in listBoxCategories.Items)
            {
                CategoryTableAdapter cta             = new CategoryTableAdapter(dataBase);
                CategoryDataSet.CategoryDataTable dt = cta.GetDataById(item.Category.CategoryID);
                dt[0].Order = index;

                cta.Update(dt);

                index++;
            }
        }
Ejemplo n.º 20
0
        void categoryGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            CategoryTableAdapter categoryAdapter = new CategoryTableAdapter();

            int categoryId = Int32.Parse(e.CommandArgument.ToString());

            if (e.CommandName == "up")
            {
                categoryAdapter.MoveUp(categoryId);
            }
            else if (e.CommandName == "down")
            {
                categoryAdapter.MoveDown(categoryId);
            }
        }
        void saveButton_Click(object sender, EventArgs e)
        {
            categoryId = Int32.Parse(idHidden.Value);

            String name = nameBox.Text.Trim();

            if (name == String.Empty)
            {
                ErrorMessage = "Name cannot be blank";
                return;
            }

            CategoryTableAdapter categoryAdapter = new CategoryTableAdapter();

            if (categoryId > 0)
            {
                category = categoryAdapter.GetCategory(categoryId)[0];


                category.Name = name;

                categoryAdapter.Update(category);

                parentCategoryId = category.ParentCategoryId;
            }
            else if (isNew == true && isSubCategory == false && Request.QueryString["parent_id"] == "NEW")
            {
                categoryAdapter.Insert(StationId, null, name, -1);
            }
            else
            {
                parentCategoryId = Int32.Parse(parentIdHidden.Value);

                // SeqNo of -1 will assign it the next highest SeqNo for the category

                categoryAdapter.Insert(StationId, parentCategoryId, name, -1);
            }

            InfoMessage = "Category Updated";
            if (parentCategoryId > 0)
            {
                Response.Redirect("~/admin/CategoryEdit.aspx?id=" + parentCategoryId);
            }
            else
            {
                Response.Redirect("~/admin/CategoryList.aspx");
            }
        }
Ejemplo n.º 22
0
        private void FormSale_Load(object sender, EventArgs e)
        {
            txtCashier.Text = $"{Program.StaffID} : {Program.KHName} : {Program.ENGName}";
            //Customer
            CustomerTableAdapter cust_adpater = new CustomerTableAdapter();

            cust_adpater.Connection = Program.Connection;
            cust_adpater.Fill(dataset.Customer);

            cboCustomer.DisplayMember = "Name";
            cboCustomer.ValueMember   = "ID";
            cboCustomer.DataSource    = dataset.Customer;
            cboCustomer.SelectedIndex = -1;
            //Category
            CategoryTableAdapter cate_adapter = new CategoryTableAdapter();

            cate_adapter.Connection = Program.Connection;
            cate_adapter.Fill(dataset.Category);

            foreach (var cate in dataset.Category)
            {
                Button btnCategory = new Button();
                btnCategory.Text   = cate.Name;
                btnCategory.Tag    = cate.ID;
                btnCategory.Width  = flowLayoutPanel_Category.Width;
                btnCategory.Height = 30;
                btnCategory.Click += BtnCategory_Click;
                flowLayoutPanel_Category.Controls.Add(btnCategory);
            }
            //
            dataGridView_Purchasing_Items.DataSource         = dataset.PurchasingItems;
            dataGridView_Purchasing_Items.Columns[0].Visible = false;//ProductID
            //add
            DataGridViewImageColumn plus = new DataGridViewImageColumn();

            //plus.HeaderText = "";
            plus.ImageLayout = DataGridViewImageCellLayout.Zoom;
            plus.Image       = Properties.Resources.Plus_32px;
            DataGridViewImageColumn delete = new DataGridViewImageColumn();

            //delete.HeaderText = "";
            delete.ImageLayout = DataGridViewImageCellLayout.Zoom;
            delete.Image       = Properties.Resources.Cancel_16px1;
            dataGridView_Purchasing_Items.Columns.Add(plus);
            dataGridView_Purchasing_Items.Columns.Add(delete);
        }
Ejemplo n.º 23
0
 private void popupBalanceR_Load(object sender, EventArgs e)
 {
     if (this.category != 0)
     {
         CategoryDataTable data = new CategoryTableAdapter().GetData();
         this.ddlAccounts.DataSource    = data;
         this.ddlAccounts.ValueMember   = "Category_ID";
         this.ddlAccounts.DisplayMember = "Category_Name";
     }
     else
     {
         COA_TDataTable mainAccounts = new COA_TTableAdapter().GetMainAccounts();
         this.ddlAccounts.DataSource    = mainAccounts;
         this.ddlAccounts.ValueMember   = "GL_ID";
         this.ddlAccounts.DisplayMember = "GL_Name_VC";
     }
 }
Ejemplo n.º 24
0
        /*public StateReport resultReport;
         *
         * public enum StateReport
         * {
         *  Close,
         *  GoReport
         * }*/

        private void ReportDataForm_Load(object sender, EventArgs e)
        {
            // TODO: данная строка кода позволяет загрузить данные в таблицу "stockDataSet.Отчет_накладные". При необходимости она может быть перемещена или удалена.
            this.WaybillReportTableAdapter.Fill(this.stockDataSet.Отчет_накладные);
            // TODO: данная строка кода позволяет загрузить данные в таблицу "stockDataSet.Накладные". При необходимости она может быть перемещена или удалена.
            this.WaybillTableAdapter.Fill(this.stockDataSet.Накладные);
            // TODO: данная строка кода позволяет загрузить данные в таблицу "stockDataSet.Отчет_остатки_товаров". При необходимости она может быть перемещена или удалена.
            this.BalanceReportTableAdapter.Fill(this.stockDataSet.Отчет_остатки_товаров);
            TrafficReportTableAdapter.Fill(stockDataSet.Отчет_по_движению_товаров);
            ListOrganizationsTableAdapter.Fill(stockDataSet.Организации_поставившие_товар);
            TOOTableAdapter.Fill(stockDataSet.ТОО_поставившая_товар);
            DivisionsTableAdapter.Fill(stockDataSet.Подразделения);
            ShippedTableAdapter.Fill(stockDataSet.Отгруженные_товары);
            WealthTableAdapter.Fill(stockDataSet.Материальные_ценности);
            ListProductsTableAdapter.Fill(stockDataSet.Пречень_товаров);
            CategoryTableAdapter.Fill(stockDataSet.Категории_товара);
        }
Ejemplo n.º 25
0
        protected override void OnPreInit(EventArgs e)
        {
            int categoryId = GetValueFromQueryString("category_id");

            if (categoryId > 0)
            {
                CategoryTableAdapter categoryAdapter = new CategoryTableAdapter();

                DollarSaverDB.CategoryDataTable categories = categoryAdapter.GetCategory(categoryId);

                if (categories.Count == 1)
                {
                    category = categories[0];
                }
            }

            base.OnPreInit(e);
        }
Ejemplo n.º 26
0
    public void StronglyTypedDataSet()
    {
        DataSet1.CategoryDataTable CategoryDT        = new DataSet1.CategoryDataTable();
        CategoryTableAdapter       CategoryTBAdapter = new CategoryTableAdapter();

        DataSet1.ProductsDataTable ProductsDT        = new DataSet1.ProductsDataTable();
        ProductsTableAdapter       ProductsTBAdapter = new ProductsTableAdapter();

        CategoryTBAdapter.Fill(CategoryDT);
        ProductsTBAdapter.Fill(ProductsDT);

        var result = from cat in CategoryDT
                     join prod in ProductsDT
                     on cat.CategoryID equals prod.CategoryID
                     where cat.CategoryID == 65985
                     select new { CategoryName = cat.CategoryName, ProductName = prod.ProductName, UnitPrice = prod.UnitPrice };

        GridView6.DataSource = result;
        GridView6.DataBind();
    }
Ejemplo n.º 27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DataSet1.CategoryDataTable Category = new DataSet1.CategoryDataTable();
        CategoryTableAdapter catAdap = new CategoryTableAdapter();

        DataSet1.ProductsDataTable Products = new DataSet1.ProductsDataTable();
        ProductsTableAdapter prodAdap = new ProductsTableAdapter();

        catAdap.Fill(Category);
        prodAdap.Fill(Products);

        var result = from item in Products
                     select item;

        DataTable queriedProducts = result.CopyToDataTable<DataSet1.ProductsRow>();
        queriedProducts.TableName = "queriedProducts";
        DataSet1 ds = new DataSet1();
        ds.Tables.Add(queriedProducts);
        //DataView view = result.AsDataView<DataSet1.ProductsRow>();
        //view.RowFilter = "CategoryID = 65985";
        GridView1.DataSource = ds.Tables["queriedProducts"];
        GridView1.DataBind();
    }
Ejemplo n.º 28
0
        private void FillList()
        {
            listBoxCategories.Items.Clear();

            CategoryTableAdapter cta = new CategoryTableAdapter(dataBase);

            CategoryDataSet.CategoryDataTable cdt = cta.GetData();

            if (checkBoxAutoSort.Checked)
            {
                foreach (CategoryDataSet.CategoryRow category in cdt.OrderBy(x => x.Name))
                {
                    listBoxCategories.Items.Add(new ListBoxItem(category));
                }
            }
            else
            {
                foreach (CategoryDataSet.CategoryRow category in cdt.OrderBy(x => x.Order))
                {
                    listBoxCategories.Items.Add(new ListBoxItem(category));
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            saveButton.Click   += new EventHandler(saveButton_Click);
            cancelButton.Click += new EventHandler(cancelButton_Click);


            if (Station.SiteTypeId != (int)SiteType.Standard)
            {
                Response.Redirect("~/admin/Default.aspx");
            }

            specialTable = specialAdapter.GetStationSpecial(StationId, 1);
            if (specialTable.Count == 1)
            {
                specialOne = specialTable[0];
            }
            specialTable = specialAdapter.GetStationSpecial(StationId, 2);
            if (specialTable.Count == 1)
            {
                specialTwo = specialTable[0];
            }
            specialTable = specialAdapter.GetStationSpecial(StationId, 3);
            if (specialTable.Count == 1)
            {
                specialThree = specialTable[0];
            }
            specialTable = specialAdapter.GetStationSpecial(StationId, 4);
            if (specialTable.Count == 1)
            {
                specialFour = specialTable[0];
            }

            if (!Page.IsPostBack)
            {
                CategoryTableAdapter            categoryAdapter = new CategoryTableAdapter();
                DollarSaverDB.CategoryDataTable categories      = categoryAdapter.GetPrimaryCategoriesByStation(StationId);

                CertificateTableAdapter            certificateAdapter = new CertificateTableAdapter();
                DollarSaverDB.CertificateDataTable certificates       = certificateAdapter.GetActive(StationId);

                //certificates.DefaultView.Sort

                SpecialSettingsTableAdapter            specialSettingsAdapter = new SpecialSettingsTableAdapter();
                DollarSaverDB.SpecialSettingsDataTable specialSettingsTable   = specialSettingsAdapter.GetSpecialSettings(StationId);

                if (specialSettingsTable.Count == 1)
                {
                    if (specialSettingsTable[0].DailyHeader)
                    {
                        dailyWeeklyList.SelectedValue = "1";
                    }
                    else
                    {
                        dailyWeeklyList.SelectedValue = "2";
                    }
                }

                // Daily/Weekly Special 1

                /*
                 * specialOneCategoryList.DataSource = categories;
                 * specialOneCategoryList.DataTextField = "Name";
                 * specialOneCategoryList.DataValueField = "CategoryId";
                 * specialOneCategoryList.DataBind();
                 */

                specialOneCertificateList.DataSource     = certificates.Rows;
                specialOneCertificateList.DataTextField  = "AdvertiserAndCertificate";
                specialOneCertificateList.DataValueField = "CertificateId";
                specialOneCertificateList.DataBind();


                if (specialOne != null)
                {
                    if (!specialOne.IsCertificateIdNull())
                    {
                        //specialOneCertificateBox.Checked = true;

                        if (certificates.FindByCertificateId(specialOne.CertificateId) != null)
                        {
                            specialOneCertificateList.SelectedValue = specialOne.CertificateId.ToString();
                        }
                    }

                    /*
                     * else if (!specialOne.IsCategoryIdNull()) {
                     *  specialOneCategoryBox.Checked = true;
                     *
                     *  specialOneCategoryList.SelectedValue = specialOne.CategoryId.ToString();
                     * } else {
                     *  specialOneRandomBox.Checked = true;
                     * }
                     */
                }

                // Special 2
                specialTwoCategoryList.DataSource     = categories;
                specialTwoCategoryList.DataTextField  = "Name";
                specialTwoCategoryList.DataValueField = "CategoryId";
                specialTwoCategoryList.DataBind();

                specialTwoCertificateList.DataSource     = certificates.Rows;
                specialTwoCertificateList.DataTextField  = "AdvertiserAndCertificate";
                specialTwoCertificateList.DataValueField = "CertificateId";
                specialTwoCertificateList.DataBind();

                if (specialTwo != null)
                {
                    if (!specialTwo.IsCertificateIdNull())
                    {
                        specialTwoCertificateBox.Checked = true;

                        if (certificates.FindByCertificateId(specialTwo.CertificateId) != null)
                        {
                            specialTwoCertificateList.SelectedValue = specialTwo.CertificateId.ToString();
                        }
                    }
                    else if (!specialTwo.IsCategoryIdNull())
                    {
                        specialTwoCategoryBox.Checked = true;

                        specialTwoCategoryList.SelectedValue = specialTwo.CategoryId.ToString();
                    }
                    else
                    {
                        specialTwoRandomBox.Checked = true;
                    }
                }


                // Special 3
                specialThreeCategoryList.DataSource     = categories;
                specialThreeCategoryList.DataTextField  = "Name";
                specialThreeCategoryList.DataValueField = "CategoryId";
                specialThreeCategoryList.DataBind();

                specialThreeCertificateList.DataSource     = certificates.Rows;
                specialThreeCertificateList.DataTextField  = "AdvertiserAndCertificate";
                specialThreeCertificateList.DataValueField = "CertificateId";
                specialThreeCertificateList.DataBind();

                if (specialThree != null)
                {
                    if (!specialThree.IsCertificateIdNull())
                    {
                        specialThreeCertificateBox.Checked = true;

                        if (certificates.FindByCertificateId(specialThree.CertificateId) != null)
                        {
                            specialThreeCertificateList.SelectedValue = specialThree.CertificateId.ToString();
                        }
                    }
                    else if (!specialThree.IsCategoryIdNull())
                    {
                        specialThreeCategoryBox.Checked = true;

                        specialThreeCategoryList.SelectedValue = specialThree.CategoryId.ToString();
                    }
                    else
                    {
                        specialThreeRandomBox.Checked = true;
                    }
                }

                // Special 4
                specialFourCategoryList.DataSource     = categories;
                specialFourCategoryList.DataTextField  = "Name";
                specialFourCategoryList.DataValueField = "CategoryId";
                specialFourCategoryList.DataBind();

                specialFourCertificateList.DataSource     = certificates.Rows;
                specialFourCertificateList.DataTextField  = "AdvertiserAndCertificate";
                specialFourCertificateList.DataValueField = "CertificateId";
                specialFourCertificateList.DataBind();

                if (specialFour != null)
                {
                    if (!specialFour.IsCertificateIdNull())
                    {
                        specialFourCertificateBox.Checked = true;

                        if (certificates.FindByCertificateId(specialFour.CertificateId) != null)
                        {
                            specialFourCertificateList.SelectedValue = specialFour.CertificateId.ToString();
                        }
                    }
                    else if (!specialFour.IsCategoryIdNull())
                    {
                        specialFourCategoryBox.Checked = true;

                        specialFourCategoryList.SelectedValue = specialFour.CategoryId.ToString();
                    }
                    else
                    {
                        specialFourRandomBox.Checked = true;
                    }
                }
            }
        }
        void saveButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                StationTableAdapter stationAdapter = new StationTableAdapter();

                String name          = nameBox.Text.Trim();
                int    siteTypeId    = Int32.Parse(siteTypeList.SelectedValue);
                int    stationTypeId = Int32.Parse(stationTypeList.SelectedValue);
                String phoneNumber   = phoneNumberBox.Text.Trim();
                String address1      = address1Box.Text.Trim();
                String address2      = address2Box.Text.Trim();
                String city          = cityBox.Text.Trim();
                String stateCode     = stateList.SelectedValue;
                String zipCode       = zipCodeBox.Text.Trim();
                int    timeZoneId    = Int32.Parse(timeZoneList.SelectedValue);
                //bool affectedByDST = daylightSavingsBox.Checked;
                String stationUrl = stationUrlBox.Text.Trim();
                String siteName   = siteNameBox.Text.Trim();
                String content1   = content1Box.Text.Trim();
                String content2   = content2Box.Text.Trim();
                //bool isActive = isActiveBox.Checked;

                if (name == String.Empty)
                {
                    ErrorMessage = "Name is required";
                    return;
                }


                if (phoneNumber == String.Empty)
                {
                    ErrorMessage = "Phone Number is required";
                    return;
                }

                if (address1 == String.Empty)
                {
                    ErrorMessage = "Address 1 is required";
                    return;
                }

                if (city == String.Empty)
                {
                    ErrorMessage = "City is required";
                    return;
                }

                if (zipCode == String.Empty)
                {
                    ErrorMessage = "Zip Code is required";
                    return;
                }

                if (stationUrl != String.Empty)
                {
                    stationUrl = stationUrlStart.SelectedValue + stationUrl;

                    // come up with a better validation...
                    if (!Uri.IsWellFormedUriString(stationUrl, UriKind.Absolute))
                    {
                        ErrorMessage = "Please enter a valid Station Website";
                        return;
                    }
                }

                if (stationUrl.Length > 500)
                {
                    stationUrl = stationUrl.Substring(0, 500);
                }

                /*
                 * if (content1 == String.Empty) {
                 *  ErrorMessage = "Content 1 is required";
                 *  return;
                 * }*/

                if (content1.Length > 1000)
                {
                    content1 = content1.Substring(0, 1000);
                }


                /*
                 * if (content2 == String.Empty) {
                 *  ErrorMessage = "Content 2 is required";
                 *  return;
                 * }*/

                if (content2.Length > 1000)
                {
                    content2 = content2.Substring(0, 1000);
                }

                siteName = siteName.Replace("<br />", "");

                if (siteName.Length > 500)
                {
                    siteName = siteName.Substring(0, 500);
                }

                String siteNameCheck = Regex.Replace(siteName, "<[^>]+>", "").Replace("&nbsp;", "").Trim();

                if (siteNameCheck == String.Empty)   // only leftover formatting in site name
                {
                    siteName = String.Empty;
                }

                if (Station != null)
                {
                    Station.Name          = name;
                    Station.SiteTypeId    = Int32.Parse(siteTypeList.SelectedValue);
                    Station.StationTypeId = Int32.Parse(stationTypeList.SelectedValue);
                    Station.PhoneNumber   = phoneNumber;
                    Station.Address1      = address1;
                    Station.Address2      = address2;
                    Station.City          = city;
                    Station.StateCode     = stateList.SelectedValue;
                    Station.ZipCode       = zipCode;
                    Station.TimeZoneId    = Int32.Parse(timeZoneList.SelectedValue);
                    //Station.AffectedByDST = daylightSavingsBox.Checked;
                    if (stationUrl != String.Empty)
                    {
                        Station.StationUrl = stationUrl;
                    }
                    else
                    {
                        Station.SetStationUrlNull();
                    }

                    if (siteName != String.Empty)
                    {
                        Station.SiteName = siteName;
                    }
                    else
                    {
                        Station.SetSiteNameNull();
                    }

                    Station.Content1 = content1;
                    Station.Content2 = content2;
                    //Station.IsActive = isActiveBox.Checked;
                    Station.IsSiteActive = isSiteActiveBox.Checked;

                    stationAdapter.Update(Station);
                    InfoMessage = "Station Updated";
                }
                else
                {
                    if (IsSuperAdmin)
                    {
                        String code = codeBox.Text.Trim().ToUpper();

                        if (code == String.Empty)
                        {
                            ErrorMessage = "Code is required";
                            return;
                        }

                        if (code.Length < 3 || code.Length > 20)
                        {
                            ErrorMessage = "Code must be between 3 and 20 characters";
                            return;
                        }

                        DollarSaverDB.StationDataTable stationCodeLookup = stationAdapter.GetByCode(code);

                        if (stationCodeLookup.Count == 1 && (Station == null || stationCodeLookup[0].StationId != Station.StationId))
                        {
                            InfoMessage = "Code is already in use";
                            return;
                        }

                        int stationId = Convert.ToInt32(stationAdapter.InsertPK(name, code, stationTypeId, siteTypeId, phoneNumber, address1, address2,
                                                                                city, stateCode, zipCode, timeZoneId, false, DateTime.Now, DateTime.Now, true,
                                                                                content1, content2, Globals.ConvertToNull(stationUrl), Globals.ConvertToNull(siteName), isSiteActiveBox.Checked, null));

                        Station = stationAdapter.GetStation(stationId)[0];

                        CategoryTableAdapter categoryAdapter = new CategoryTableAdapter();
                        categoryAdapter.Insert(stationId, null, "Restaurants & Food", 1);
                        categoryAdapter.Insert(stationId, null, "Things To Do", 2);
                        categoryAdapter.Insert(stationId, null, "Home & Garden", 3);
                        categoryAdapter.Insert(stationId, null, "Health & Beauty", 4);
                        categoryAdapter.Insert(stationId, null, "Retail", 5);
                        categoryAdapter.Insert(stationId, null, "Automotive", 6);

                        StationContentTableAdapter stationContentTableAdapter = new StationContentTableAdapter();
                        stationContentTableAdapter.Insert(stationId, null, null, null, null, null, null, null, null, null);

                        DealSettingsTableAdapter dealSettingsAdapter = new DealSettingsTableAdapter();
                        dealSettingsAdapter.Insert(stationId, 1, 8, 4, 10);

                        SpecialSettingsTableAdapter specialSettingAdapter = new SpecialSettingsTableAdapter();
                        specialSettingAdapter.Insert(stationId, true);

                        if (!Directory.Exists(Request.PhysicalApplicationPath + Station.StationDirUrl))
                        {
                            Directory.CreateDirectory(Request.PhysicalApplicationPath + Station.StationDirUrl);
                        }

                        if (!Directory.Exists(Request.PhysicalApplicationPath + Station.ImageDirUrl))
                        {
                            Directory.CreateDirectory(Request.PhysicalApplicationPath + Station.ImageDirUrl);
                        }
                    }
                }

                RedirectToHomePage();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            saveButton.Click   += new EventHandler(saveButton_Click);
            cancelButton.Click += new EventHandler(cancelButton_Click);
            deleteButton.Click += new EventHandler(deleteButton_Click);
            deleteButton.Attributes["onclick"] = "javascript: return confirm('Are you sure want to delete this item?');";

            subCategoryGrid.RowCommand += new GridViewCommandEventHandler(subCategoryGrid_RowCommand);

            categoryId = GetIdFromQueryString();

            CategoryTableAdapter categoryAdapter = new CategoryTableAdapter();


            if (categoryId != 0)
            {
                DollarSaverDB.CategoryDataTable categories = categoryAdapter.GetCategory(categoryId);


                if (categories.Rows.Count != 1)
                {
                    Response.Redirect("~/admin/CategoryList.aspx");
                }

                category = categories[0];

                if (category.StationId != StationId)
                {
                    Response.Redirect("~/admin/CategoryList.aspx");
                }

                if (!category.IsParentCategoryIdNull())
                {
                    parentCategoryId = category.ParentCategoryId;

                    parentCategory = categoryAdapter.GetCategory(parentCategoryId)[0];
                }
            }
            else
            {
                parentCategoryId = GetParentIdFromQueryString();

                DollarSaverDB.CategoryDataTable parentCategories = categoryAdapter.GetCategory(parentCategoryId);

                if (parentCategories.Rows.Count != 1)
                {
                    Response.Redirect("~/admin/CategoryList.aspx");
                }

                parentCategory = parentCategories[0];

                if (parentCategory.StationId != StationId)
                {
                    Response.Redirect("~/admin/CategoryList.aspx");
                }

                isNew = true;
            }

            if (isNew || !category.IsParentCategoryIdNull())
            {
                isSubCategory = true;
            }
        }
Ejemplo n.º 32
0
    public void DataViewDemo()
    {
        DataSet1.CategoryDataTable Category = new DataSet1.CategoryDataTable();
        CategoryTableAdapter catAdap = new CategoryTableAdapter();
        catAdap.Fill(Category);

        DataSet1.ProductsDataTable Products = new DataSet1.ProductsDataTable();
        ProductsTableAdapter prodAdap = new ProductsTableAdapter();
        prodAdap.Fill(Products);

        var result = from item in Products
                     select item;
        DataView view = result.AsDataView();
        view.Sort = "ProductName desc";
        view.RowFilter = "CategoryID = 65985";        
        GridView7.DataSource = view;
        GridView7.DataBind();
        DataSet1.ProductsRow row = null;
        List<DataSet1.ProductsRow> myList = new List<DataSet1.ProductsRow>();
        foreach (DataRowView item in view)
        {
            row = (DataSet1.ProductsRow)item.Row;
            myList.Add(row);
        }
        GridView8.DataSource = myList;
        GridView8.DataBind();
    }
Ejemplo n.º 33
0
    public void StronglyTypedDataSet()
    {
        DataSet1.CategoryDataTable CategoryDT = new DataSet1.CategoryDataTable();
        CategoryTableAdapter CategoryTBAdapter = new CategoryTableAdapter();

        DataSet1.ProductsDataTable ProductsDT = new DataSet1.ProductsDataTable();        
        ProductsTableAdapter ProductsTBAdapter = new ProductsTableAdapter();

        CategoryTBAdapter.Fill(CategoryDT);
        ProductsTBAdapter.Fill(ProductsDT);

        var result = from cat in CategoryDT
                     join prod in ProductsDT
                     on cat.CategoryID equals prod.CategoryID
                     where cat.CategoryID == 65985
                     select new { CategoryName = cat.CategoryName, ProductName = prod.ProductName, UnitPrice = prod.UnitPrice };        

        GridView6.DataSource = result;
        GridView6.DataBind();
    }
Ejemplo n.º 34
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            try
            {
                this.BindingContext[this.categoryDetailDataSet, CATEGORY].EndCurrentEdit();
                this.BindingContext[this.categoryDetailDataSet, LOCALIZED_CATEGORY_NAME].EndCurrentEdit();

                DataRowView view = this.BindingContext[categoryDetailDataSet, CATEGORY].Current as DataRowView;
                CategoryDetailDataSet.CategoryRow row = view.Row as CategoryDetailDataSet.CategoryRow;

                if (row.IsImageNull())
                {
                    this.DialogResult = DialogResult.None;

                    // Initializes the variables to pass to the MessageBox.Show method.

                    string message = Resources.ImageNotSetMessage;
                    string caption = Resources.ErrorCaption;

                    // Displays the MessageBox.

                    MessageBox.Show(this, message, caption, MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);

                    return;
                }

                foreach (CategoryDetailDataSet.LocalizedCategoryNameRow localizedNameRow in this.categoryDetailDataSet.LocalizedCategoryName.Rows)
                {
                    if (localizedNameRow.CultureName == this.cultureName)
                    {
                        if (localizedNameRow.IsNameNull() || localizedNameRow.Name.Trim().Length == 0)
                        {
                            this.DialogResult = DialogResult.None;

                            // Initializes the variables to pass to the MessageBox.Show method.

                            string message = string.Format(Resources.CannotBeEmptyMessage, localizedNameRow.Language);
                            string caption = Resources.ErrorCaption;

                            // Displays the MessageBox.

                            MessageBox.Show(this, message, caption, MessageBoxButtons.OK,
                                            MessageBoxIcon.Error);

                            return;
                        }

                        break;
                    }
                }

                CategoryDetailDataSet changes = (CategoryDetailDataSet)categoryDetailDataSet.GetChanges();
                if (changes != null)
                {
                    CategoryTableAdapter categoryAdapter = new CategoryTableAdapter();
                    categoryAdapter.Connection.Open();
                    categoryAdapter.Update(changes);

                    SqlCommand sqlUpdateCommand = new SqlCommand();
                    sqlUpdateCommand.Connection  = categoryAdapter.Connection;
                    sqlUpdateCommand.CommandText = @"UPDATE Resource SET [Text] = @Text "
                                                   + "WHERE (ResourceId = @ResourceId AND CultureId = @CultureId) ";

                    sqlUpdateCommand.Parameters.Add(new SqlParameter("@Text", System.Data.SqlDbType.NText, 0, "Text"));
                    sqlUpdateCommand.Parameters.Add(new SqlParameter("@ResourceId", System.Data.SqlDbType.UniqueIdentifier, 0, "ResourceId"));
                    sqlUpdateCommand.Parameters.Add(new SqlParameter("@CultureId", System.Data.SqlDbType.Int, 0, "CultureId"));

                    SqlCommand sqlInsertCommand = new SqlCommand();
                    sqlInsertCommand.Connection  = categoryAdapter.Connection;
                    sqlInsertCommand.CommandText = @"INSERT INTO Resource([Text], ResourceId, CultureId) VALUES(@Text, @ResourceId, @CultureId) ";

                    sqlInsertCommand.Parameters.Add(new SqlParameter("@Text", System.Data.SqlDbType.NText, 0, "Text"));
                    sqlInsertCommand.Parameters.Add(new SqlParameter("@ResourceId", System.Data.SqlDbType.UniqueIdentifier, 0, "ResourceId"));
                    sqlInsertCommand.Parameters.Add(new SqlParameter("@CultureId", System.Data.SqlDbType.Int, 0, "CultureId"));

                    Guid resourceId = row.Name;

                    DataRow[] rows = this.categoryDetailDataSet.LocalizedCategoryName.Select("", "", DataViewRowState.ModifiedCurrent);

                    foreach (DataRow modifiedRow in rows)
                    {
                        if (modifiedRow.IsNull("ResourceId"))
                        {
                            sqlInsertCommand.Parameters["@Text"].Value       = modifiedRow["Name"];
                            sqlInsertCommand.Parameters["@ResourceId"].Value = resourceId;
                            sqlInsertCommand.Parameters["@CultureId"].Value  = modifiedRow["CultureId"];
                            sqlInsertCommand.ExecuteNonQuery();
                        }
                        else
                        {
                            sqlUpdateCommand.Parameters["@Text"].Value       = modifiedRow["Name"];
                            sqlUpdateCommand.Parameters["@ResourceId"].Value = resourceId;
                            sqlUpdateCommand.Parameters["@CultureId"].Value  = modifiedRow["CultureId"];
                            sqlUpdateCommand.ExecuteNonQuery();
                        }
                    }

                    categoryAdapter.Connection.Close();
                }
            }
            catch (Exception ex)
            {
                ReportError(ex.Message.ToString());
                this.DialogResult = DialogResult.Cancel;
            }
        }