Exemplo n.º 1
0
        private string SaveUser(string tbxFname, string tbxLname, string tbxLogin, int IdUser)
        {
            ADOHelper helper = new ADOHelper("user_insert");

            helper.AddParameter("@user_grou_id", 6);
            helper.AddParameter("@user_fname", tbxFname);
            helper.AddParameter("@user_lname", tbxLname);
            helper.AddParameter("@user_login", tbxLogin);
            helper.AddParameter("@user_user_mod_id", IdUser);
            var a = helper.ExecuteScalar();

            return(a.ToString());
        }
Exemplo n.º 2
0
        private void SaveUserData(string tbxImię, string tbxLogin, string tbxNazwisko, bool cbActive, string ddlGroup, int UserIdtoChange, int UserId)
        {
            ADOHelper helper = new ADOHelper("user_data_save");

            helper.AddParameter("@user_fname", tbxImię);
            helper.AddParameter("@user_login", tbxLogin);
            helper.AddParameter("@user_lname", tbxNazwisko);
            helper.AddParameter("@user_active", cbActive ? 1 : 0);
            helper.AddParameter("@user_grou_id", ddlGroup);
            helper.AddParameter("@user_id", UserIdtoChange);
            helper.AddParameter("@user_user_mod", UserId);
            helper.ExecuteNonQuery();
        }
Exemplo n.º 3
0
        protected void gvMessageInfo_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            Success.Text = "";
            //lbtnData.BorderWidth = 1;
            //lbtnPassword.BorderWidth = 0;
            dData.Visible = true;
            GridViewRow row = gvMessageInfo.Rows[e.NewSelectedIndex];

            pClient.Visible  = true;
            tbxBDate.Text    = row.Cells[3].Text.Substring(0, 10);
            tbxImię.Text     = row.Cells[4].Text;
            tbxNazwisko.Text = row.Cells[5].Text;
            tbxSaldo.Text    = row.Cells[7].Text;
            tbxNip.Text      = row.Cells[8].Text;
            tbxStreet.Text   = row.Cells[9].Text;
            tbxHome.Text     = row.Cells[10].Text;
            tbxCity.Text     = row.Cells[11].Text;
            tbxZip.Text      = row.Cells[12].Text;
            //ddlPlec.SelectedValue = row.Cells[6].Text;
            if (row.Cells[6].Text == "Mężczyzna")
            {
                ddlPlec.SelectedValue = "m";
            }
            else
            {
                ddlPlec.SelectedValue = "k";
            }
            //tbxPath.Text = row.Cells[8].Text;
            //ddlCategories.SelectedItem.Text = row.Cells[4].Text;
            //setSelectedRow(row.Cells[1].Text);
            ddlGroup.SelectedValue = row.Cells[15].Text;
            cbActive.Checked       = row.Cells[16].Text == "1" ? true : false;
            tbxLogin.Text          = row.Cells[17].Text;
            Session["ClieId"]      = row.Cells[1].Text;
            ADOHelper helper = new ADOHelper("client_history_get");

            helper.AddParameter("@clie_id", row.Cells[1].Text);
            DataTable dt = helper.Execute();

            gvHistory.DataSource = dt;
            gvHistory.DataBind();
            SwitchDiv(true);

            helper = new ADOHelper("user_history_get");
            helper.AddParameter("@user_id", row.Cells[2].Text);
            dt = helper.Execute();
            gvHistoryUser.DataSource = dt;
            gvHistoryUser.DataBind();

            ChangeColumns(sender);
        }
Exemplo n.º 4
0
        private void GetData()
        {
            ADOHelper helper = new ADOHelper("statuses_get");
            DataTable dt     = helper.Execute();


            ddlStatuses.DataTextField  = "stat_name";
            ddlStatuses.DataValueField = "stat_id";
            ddlStatuses.DataSource     = dt;
            ddlStatuses.DataBind();
            Session["statuses"] = dt;
            //dt.Columns.Remove("user_password");
            //dt.Columns.Remove("user_date_pass");
        }
Exemplo n.º 5
0
        private void SaveProduct(string tbxNazwa, string tbxIlosc, decimal tbxPrice, bool cbBanner, string tbxOpis, string tbxPath, int ddlCategories, int IdUser)
        {
            ADOHelper helper = new ADOHelper("product_add");

            helper.AddParameter("@prod_name", tbxNazwa);
            helper.AddParameter("@prod_quantity", tbxIlosc);
            helper.AddParameter("@prod_price", tbxPrice);
            helper.AddParameter("@prod_banner", cbBanner);
            helper.AddParameter("@prod_desc", tbxOpis);
            helper.AddParameter("@prod_path", tbxPath);
            helper.AddParameter("@prod_cate_id", ddlCategories);
            helper.AddParameter("@prod_user_id", IdUser);
            helper.ExecuteNonQuery();
        }
Exemplo n.º 6
0
        public static void TestAdoHelper()
        {
            ADOHelper ado = new ADOHelper("AdventureWorks2008R2");
            string    sql = "Select * from HumanResources.Employee";

            try
            {
                DataSet ds = ado.ExecuteDataSet(sql);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         ADOHelper helper = new ADOHelper("categories_get");
         DataTable dt     = helper.Execute();
         ddlCategories.DataTextField  = "cate_name";
         ddlCategories.DataValueField = "cate_id";
         ddlCategories.DataSource     = dt;
         ddlCategories.DataBind();
         ControlProject.VisibleMenu(true, this);
         ControlProject.CheckSession(this);
     }
 }
Exemplo n.º 8
0
        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            container
            .RegisterType <IDataContextAsync, MisukaDBContext>(new PerRequestLifetimeManager())
            .RegisterType <IRepositoryProvider, RepositoryProvider>(
                new PerRequestLifetimeManager(),
                new InjectionConstructor(new object[] { new RepositoryFactories() })
                )
            .RegisterType <IUnitOfWorkAsync, UnitOfWork>(new PerRequestLifetimeManager());
            new ServiceRegister(container).Register();
            var ado = new ADOHelper();

            ADO.AdoHelper = ado;
        }
 /// <summary>
 /// Insere ou atualiza dados do produto atual.
 /// </summary>
 private void InsertOrUpdateProduct()
 {
     //Verifica se todos os campos obrigatórios estão preenchidos.
     if ((currentProduct.name != null && selectedProvider != null) && (currentProduct.name != "" && selectedProvider != ""))
     {
         //Insere um novo Produto
         if (currentProduct.id == 0)
         {
             DataTable providerFounded = ADOHelper.QueryProvidersByName(mainWindowContext.connectionString, selectedProvider);
             currentProduct.provider_id = (int)providerFounded.Rows[0][0];
             DataTable productFounded = ADOHelper.QueryProductsByName(mainWindowContext.connectionString, currentProduct.name, "=");
             if (productFounded.Rows.Count == 0)
             {
                 EFContext.products.Add(currentProduct);
                 EFContext.SaveChanges();
                 RefreshEFContext();
                 productFounded    = ADOHelper.QueryProductsByName(mainWindowContext.connectionString, currentProduct.name);
                 currentProduct.id = (int)productFounded.Rows[0][0];
                 ResetProductFields();
                 ButtonsHandler();
                 SearchProduct();
                 isRegisterTabFocused = false;
                 isQueryTabFocused    = true;
             }
             else
             {
                 msgBox = new AlphaMessageBox(mainWindowContext.productWindow, "Já existe um produto com este nome.");
                 msgBox.ShowDialog();
             }
         }
         else
         {
             product   oldProduct      = EFContext.products.Find(currentProduct.id);
             DataTable providerFounded = ADOHelper.QueryProvidersByName(mainWindowContext.connectionString, selectedProvider, "", "=");
             currentProduct.provider_id = (int)providerFounded.Rows[0][0];
             UpdateProduct(oldProduct);
             EFContext.SaveChanges();
             ResetProductFields();
             ButtonsHandler();
             SearchProduct();
             isRegisterTabFocused = false;
             isQueryTabFocused    = true;
         }
     }
     else
     {
         msgBox = new AlphaMessageBox(mainWindowContext.productWindow, "Preencha os campos obrigatórios.");
         msgBox.ShowDialog();
     }
 }
Exemplo n.º 10
0
        private void DoInsert(ref Category item, bool stopProccessingChildren)
        {
            // Don't update if the item isn't dirty.
            if (!item.IsDirty)
            {
                return;
            }

            bool cancel = false;

            OnInserting(ref cancel);
            if (cancel)
            {
                return;
            }

            const string commandText = "INSERT INTO [dbo].[Category] ([CategoryId], [Name], [Descn]) VALUES (@p_CategoryId, @p_Name, @p_Descn)";

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand(commandText, connection))
                {
                    command.Parameters.AddWithValue("@p_CategoryId", item.CategoryId);
                    command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(item.Name));
                    command.Parameters.AddWithValue("@p_Descn", ADOHelper.NullCheck(item.Description));

                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                        }
                    }
                }
            }

            item.OriginalCategoryId = item.CategoryId;

            MarkOld(item);
            CheckRules(item);

            if (!stopProccessingChildren)
            {
                // Update Child Items.
                Update_Products_Products_FK__Product__Categor__0CBAE877(ref item);
            }

            OnInserted();
        }
        private void DoInsert(ref Supplier item, bool stopProccessingChildren)
        {
            // Don't update if the item isn't dirty.
            if (!item.IsDirty)
            {
                return;
            }

            bool cancel = false;

            OnInserting(ref cancel);
            if (cancel)
            {
                return;
            }

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Supplier_Insert]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@p_SuppId", item.SuppId);
                    command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(item.Name));
                    command.Parameters.AddWithValue("@p_Status", item.Status);
                    command.Parameters.AddWithValue("@p_Addr1", ADOHelper.NullCheck(item.Addr1));
                    command.Parameters.AddWithValue("@p_Addr2", ADOHelper.NullCheck(item.Addr2));
                    command.Parameters.AddWithValue("@p_City", ADOHelper.NullCheck(item.City));
                    command.Parameters.AddWithValue("@p_State", ADOHelper.NullCheck(item.State));
                    command.Parameters.AddWithValue("@p_Zip", ADOHelper.NullCheck(item.Zip));
                    command.Parameters.AddWithValue("@p_Phone", ADOHelper.NullCheck(item.Phone));

                    command.ExecuteNonQuery();
                }
            }

            item.OriginalSuppId = item.SuppId;

            MarkOld(item);
            CheckRules(item);

            if (!stopProccessingChildren)
            {
                // Update Child Items.
                Update_Items_Items_FK__Item__Supplier__1273C1CD(ref item);
            }

            OnInserted();
        }
        private void DoInsert(ref Profile item, bool stopProccessingChildren)
        {
            // Don't update if the item isn't dirty.
            if (!item.IsDirty)
            {
                return;
            }

            bool cancel = false;

            OnInserting(ref cancel);
            if (cancel)
            {
                return;
            }

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Profile_Insert]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@p_UniqueID", item.UniqueID);
                    command.Parameters["@p_UniqueID"].Direction = ParameterDirection.Output;
                    command.Parameters.AddWithValue("@p_Username", item.Username);
                    command.Parameters.AddWithValue("@p_ApplicationName", item.ApplicationName);
                    command.Parameters.AddWithValue("@p_IsAnonymous", ADOHelper.NullCheck(item.IsAnonymous));
                    command.Parameters.AddWithValue("@p_LastActivityDate", ADOHelper.NullCheck(item.LastActivityDate));
                    command.Parameters.AddWithValue("@p_LastUpdatedDate", ADOHelper.NullCheck(item.LastUpdatedDate));

                    command.ExecuteNonQuery();

                    item.UniqueID = (System.Int32)command.Parameters["@p_UniqueID"].Value;
                }
            }


            MarkOld(item);
            CheckRules(item);

            if (!stopProccessingChildren)
            {
                // Update Child Items.
                Update_Accounts_Accounts_FK_Account_Profiles(ref item);
                Update_Carts_Carts_FK_Cart_Profiles(ref item);
            }

            OnInserted();
        }
Exemplo n.º 13
0
        private void DoInsert(ref Item item, bool stopProccessingChildren)
        {
            // Don't update if the item isn't dirty.
            if (!item.IsDirty)
            {
                return;
            }

            bool cancel = false;

            OnInserting(ref cancel);
            if (cancel)
            {
                return;
            }

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Item_Insert]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@p_ItemId", item.ItemId);
                    command.Parameters.AddWithValue("@p_ProductId", item.ProductId);
                    command.Parameters.AddWithValue("@p_ListPrice", ADOHelper.NullCheck(item.ListPrice));
                    command.Parameters.AddWithValue("@p_UnitCost", ADOHelper.NullCheck(item.UnitCost));
                    command.Parameters.AddWithValue("@p_Supplier", ADOHelper.NullCheck(item.Supplier));
                    command.Parameters.AddWithValue("@p_Status", ADOHelper.NullCheck(item.Status));
                    command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(item.Name));
                    command.Parameters.AddWithValue("@p_Image", ADOHelper.NullCheck(item.Image));

                    command.ExecuteNonQuery();
                }
            }

            item.OriginalItemId = item.ItemId;

            MarkOld(item);
            CheckRules(item);

            if (!stopProccessingChildren)
            {
                // Update Child Items.
                Update_Product_Product_FK__Item__ProductId__117F9D94(ref item);
                Update_SupplierMember_SupplierMember_FK__Item__Supplier__1273C1CD(ref item);
            }

            OnInserted();
        }
Exemplo n.º 14
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ADOHelper helper = new ADOHelper("groups_get");
            DataTable dt     = helper.Execute();

            if (tbxNazwa.Text.Length < 2)
            {
                FailureText.Text = "Nazwa grupy jest zbyt krótka";
                return;
            }
            if (tbxNazwa.Text.Length > 49)
            {
                FailureText.Text = "Nazwa grupy jest zbyt długa";
                return;
            }
            try
            {
                int.Parse(tbxPerm.Text);
            }
            catch
            {
                FailureText.Text = "Poziom dostępu nie jest liczbą!";
                return;
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["grou_name"].ToString() == tbxNazwa.Text)
                {
                    FailureText.Text = "Podana grupa już istnieje!"; return;
                }

                if (dt.Rows[i]["grou_permissions"].ToString() == tbxPerm.Text)
                {
                    FailureText.Text = "Istnieje grupa o takich uprawniniach!"; return;
                }
            }
            try
            {
                FailureText.Text = "";
                SaveGroup(tbxNazwa.Text, int.Parse(tbxPerm.Text), int.Parse(Session["IdUser"].ToString()));
                Session["succes"] = "1";
                Response.Redirect("~/Accounts/Manage.aspx");
            }
            catch
            {
                FailureText.Text = "Błąd w procedurze";
            }
        }
Exemplo n.º 15
0
        private void SaveClient(string UserId, string dateTime, string ddlPlec, string tbxNip, string tbxStreet, string tbxHome, string tbxCity, string tbxZip, int IdUser)
        {
            ADOHelper helper = new ADOHelper("client_add");

            helper.AddParameter("@clie_user_id", UserId);
            helper.AddParameter("@clie_bdate", dateTime);
            helper.AddParameter("@clie_sex", ddlPlec);
            helper.AddParameter("@clie_saldo", 0);
            helper.AddParameter("@clie_nip", tbxNip);
            helper.AddParameter("@clie_street", tbxStreet);
            helper.AddParameter("@clie_home", tbxHome);
            helper.AddParameter("@clie_city", tbxCity);
            helper.AddParameter("@clie_zip", tbxZip);
            helper.AddParameter("@clie_user_mod_id", IdUser);
            helper.ExecuteNonQuery();
        }
Exemplo n.º 16
0
        private void UpdateClient(string tbxBDate, string tbxImię, string tbxNazwisko, string tbxNip, string tbxStreet, string tbxHome, string tbxCity, string tbxZip, string ddlPlec, int ClieId, int UserId)
        {
            ADOHelper helper = new ADOHelper("client_update");

            helper.AddParameter("@clie_id", ClieId);
            helper.AddParameter("@clie_bdate", tbxBDate);
            helper.AddParameter("@user_fname", tbxImię);
            helper.AddParameter("@user_lname", tbxNazwisko);
            helper.AddParameter("@clie_nip", tbxNip);
            helper.AddParameter("@clie_street", tbxStreet);
            helper.AddParameter("@clie_home", tbxHome);
            helper.AddParameter("@clie_city", tbxCity);
            helper.AddParameter("@clie_zip", tbxZip);
            helper.AddParameter("@clie_sex", ddlPlec);
            helper.AddParameter("@clie_user_id", UserId);
            helper.ExecuteNonQuery();
        }
        /// <summary>
        /// Atualiza lista de fornecedores ativos.
        /// </summary>
        private void RefreshList()
        {
            if (providersList == null)
            {
                providersList = new ObservableCollection <string>();
            }
            if (providersList.Count > 0)
            {
                providersList.Clear();
            }
            DataTable providerFounded = ADOHelper.QueryProvidersByName(mainWindowContext.connectionString, "", "1");

            for (int i = 0; i < providerFounded.Rows.Count; i++)
            {
                providersList.Add((string)providerFounded.Rows[i][1]);
            }
        }
        private void DoInsert(ref Product item, bool stopProccessingChildren)
        {
            // Don't update if the item isn't dirty.
            if (!item.IsDirty)
            {
                return;
            }

            bool cancel = false;

            OnInserting(ref cancel);
            if (cancel)
            {
                return;
            }

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Product_Insert]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@p_ProductId", item.ProductId);
                    command.Parameters.AddWithValue("@p_CategoryId", item.CategoryId);
                    command.Parameters.AddWithValue("@p_Name", ADOHelper.NullCheck(item.Name));
                    command.Parameters.AddWithValue("@p_Descn", ADOHelper.NullCheck(item.Description));
                    command.Parameters.AddWithValue("@p_Image", ADOHelper.NullCheck(item.Image));

                    command.ExecuteNonQuery();
                }
            }

            item.OriginalProductId = item.ProductId;

            MarkOld(item);
            CheckRules(item);

            if (!stopProccessingChildren)
            {
                // Update Child Items.
                Update_Category_Category_FK__Product__Categor__0CBAE877(ref item);
                Update_Items_Items_FK__Item__ProductId__117F9D94(ref item);
            }

            OnInserted();
        }
        /// <summary>
        /// Fetch SupplierList.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public SupplierList Fetch(SupplierCriteria criteria)
        {
            SupplierList item = (SupplierList)Activator.CreateInstance(typeof(SupplierList), true);

            bool cancel = false;

            OnFetching(criteria, ref cancel);
            if (cancel)
            {
                return(item);
            }

            // Fetch Child objects.
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Supplier_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_NameHasValue", criteria.NameHasValue);
                    command.Parameters.AddWithValue("@p_Addr1HasValue", criteria.Addr1HasValue);
                    command.Parameters.AddWithValue("@p_Addr2HasValue", criteria.Addr2HasValue);
                    command.Parameters.AddWithValue("@p_CityHasValue", criteria.CityHasValue);
                    command.Parameters.AddWithValue("@p_StateHasValue", criteria.StateHasValue);
                    command.Parameters.AddWithValue("@p_ZipHasValue", criteria.ZipHasValue);
                    command.Parameters.AddWithValue("@p_PhoneHasValue", criteria.PhoneHasValue);
                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            do
                            {
                                item.Add(new SupplierFactory().Map(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            MarkOld(item);
            MarkAsChild(item);
            OnFetched();
            return(item);
        }
Exemplo n.º 20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (IsPostBack)
        //    return;

        lblAdmin.Text = Request.QueryString["id"];

        string str = "SELECT * FROM tblStudent ORDER BY StudID";

        ADOHelper     obj = new ADOHelper();
        SqlDataReader dr  = obj.GetDataReader(str);

        string htm;

        htm = "<table border = 3>";
        htm = htm + "<tr>";
        htm = htm + "<th>StudID</th>";
        htm = htm + "<th>Name</th>";
        htm = htm + "<th>DOB</th>";
        htm = htm + "<th>DOJ</th>";
        htm = htm + "<th>Course</th>";
        htm = htm + "<th>...</th>";
        htm = htm + "</tr>";

        if (dr.HasRows)
        {
            do
            {
                htm = htm + "<tr>";
                htm = htm + "<td>" + dr["StudID"].ToString() + "</td>";
                htm = htm + "<td>" + dr["Name"].ToString() + "</td>";
                htm = htm + "<td>" + dr["DOB"].ToString() + "</td>";
                htm = htm + "<td>" + dr["DOJ"].ToString() + "</td>";
                htm = htm + "<td>" + dr["Course"].ToString() + "</td>";
                htm = htm + "<td><a href='Indi-details.aspx?id=" + dr["StudID"].ToString() + "&id1=" + lblAdmin.Text + "'>View</td>";
                htm = htm + "</tr>";
            } while (dr.Read());
        }
        htm = htm + "</table>";
        dr.Close();

        PlaceHolder1.Controls.Add(new Literal {
            Text = htm
        });
    }
Exemplo n.º 21
0
    protected void grdFiles_SelectedIndexChanged(object sender, EventArgs e)
    {
        string TutorialID, Filename;

        TutorialID = grdFiles.SelectedRow.Cells[0].Text;

        string query = "SELECT * FROM tblTutorial WHERE TutorialID = '" + TutorialID + "'";

        ADOHelper     obj = new ADOHelper();
        SqlDataReader dr  = obj.GetDataReader(query);

        Filename = dr["Filename"].ToString();

        Response.ContentType = "application/octet-stream";
        Response.AppendHeader("Content-Disposition", "attachment; filename=" + Filename);
        Response.TransmitFile(Server.MapPath("Tutorials//") + Filename);
        Response.End();
    }
Exemplo n.º 22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ADOHelper helper = new ADOHelper("categories_get");
            DataTable dt     = helper.Execute();

            if (!IsPostBack)
            {
                ddlCategories.DataTextField  = "cate_name";
                ddlCategories.DataValueField = "cate_id";
                ddlCategories.DataSource     = dt;
                ddlCategories.DataBind();

                helper = new ADOHelper("client_for_order_get");
                dt     = helper.Execute();
                ddlClient.DataTextField  = "name";
                ddlClient.DataValueField = "id";
                ddlClient.DataSource     = dt;
                ddlClient.DataBind();


                ControlProject.VisibleMenu(true, this);
                ControlProject.CheckSession(this);

                if (ViewState["Products"] == null)
                {
                    DataTable dtProducts = new DataTable();
                    dtProducts.Columns.AddRange(new DataColumn[3] {
                        new DataColumn("ProductId", typeof(int)),
                        new DataColumn("ProductName", typeof(string)), new DataColumn("ProductPrice", typeof(string))
                    });
                    //dtProducts.Columns["FruitId"].AutoIncrement = true;
                    //dtProducts.Columns["FruitId"].AutoIncrementSeed = 1;
                    //dtProducts.Columns["FruitId"].AutoIncrementStep = 1;
                    ViewState["Products"] = dtProducts;
                }
            }
            helper = new ADOHelper("products_get");
            helper.AddParameter("@banner", 1);
            helper.AddParameter("@prod_quantity", 0);
            dt = helper.Execute();
            gvMessageInfo.DataSource = dt;
            gvMessageInfo.DataBind();
            lbProducts.DataBind();
        }
        /// <summary>
        /// Fetch Supplier.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public Supplier Fetch(SupplierCriteria criteria)
        {
            bool cancel = false;

            OnFetching(criteria, ref cancel);
            if (cancel)
            {
                return(null);
            }

            Supplier item;

            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Supplier_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_NameHasValue", criteria.NameHasValue);
                    command.Parameters.AddWithValue("@p_Addr1HasValue", criteria.Addr1HasValue);
                    command.Parameters.AddWithValue("@p_Addr2HasValue", criteria.Addr2HasValue);
                    command.Parameters.AddWithValue("@p_CityHasValue", criteria.CityHasValue);
                    command.Parameters.AddWithValue("@p_StateHasValue", criteria.StateHasValue);
                    command.Parameters.AddWithValue("@p_ZipHasValue", criteria.ZipHasValue);
                    command.Parameters.AddWithValue("@p_PhoneHasValue", criteria.PhoneHasValue);
                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            item = Map(reader);
                        }
                        else
                        {
                            throw new Exception(String.Format("The record was not found in 'dbo.Supplier' using the following criteria: {0}.", criteria));
                        }
                    }
                }
            }

            MarkOld(item);
            OnFetched();
            return(item);
        }
Exemplo n.º 24
0
        private void GetData()
        {
            ADOHelper helper = new ADOHelper("categories_get");
            DataTable dt     = helper.Execute();


            //ddlCategories.DataTextField = "cate_name";
            //ddlCategories.DataValueField = "cate_id";
            //ddlCategories.DataSource = dt;
            //ddlCategories.DataBind();
            //Session["categories"] = dt;
            //dt.Columns.Remove("user_password");
            //dt.Columns.Remove("user_date_pass");
            helper = new ADOHelper("clients_get");
            dt     = helper.Execute();

            ////int i = 0;
            ////string d = "";
            //////var stringDataTable = new DataTable();
            //////stringDataTable.Columns.Add("DATE", typeof(String));
            //////stringDataTable.Columns.Add("TIME", typeof(String));
            ////DateTime de;

            ////foreach (DataRow dr in dt.Rows)
            ////{//"dd/MM/yyyy H:mm:ss
            ////    DateTime.TryParseExact(dr["clie_date_mod"].ToString(), "yyyy/MM/dd HH:mm:ss", null,
            ////                       System.Globalization.DateTimeStyles.AdjustToUniversal, out de);

            ////    //d = ((DateTime)dr["clie_date_mod"]).ToString("dd/MM/yyyy H:mm:ss");
            ////    dt.Rows[i]["clie_date_mod"] = de.ToString();
            ////    i++;
            ////}

            gvMessageInfo.DataSource = dt;
            gvMessageInfo.DataBind();

            helper                  = new ADOHelper("groups_get");
            dt                      = helper.Execute();
            Session["groups"]       = dt;
            ddlGroup.DataTextField  = "grou_name";
            ddlGroup.DataValueField = "grou_id";
            ddlGroup.DataSource     = dt;
            ddlGroup.DataBind();
        }
Exemplo n.º 25
0
        //保存修改
        private void button_save_Click(object sender, EventArgs e)
        {
            if (!ClassGlobalUserInfo.checkValidate())//操作员没有权限
            {
                CValidateTools.showError("权限不足");
                return;
            }

            if (textBox_cname.ReadOnly)
            {
                return;
            }

            int roleID = int.Parse(comboBox_role.SelectedValue.ToString());
            int depID  = int.Parse(comboBox_dep.SelectedValue.ToString());

            string strUpdate = "update userInfo set cName = '#cname' ,  depID = #depid , roleID = #roldid where userNumber = '#usernumber'";

            strUpdate = strUpdate.Replace("#cname", textBox_cname.Text).Replace("#depid", depID.ToString()).Replace("#roldid", roleID.ToString()).Replace("#usernumber", textBox_id.Text);

            bool result = false;

            try
            {
                ADOHelper db = new ADOHelper();
                result = db.ExecuteUpdate(strUpdate);
            }
            catch (Exception ex)
            {
                CValidateTools.showError(ex.Message);
                return;
            }


            if (result)
            {
                CValidateTools.showOK("用户修改成功!");
            }

            getUserInfo();

            textBox_cname.ReadOnly = true;
            textBox_id.ReadOnly    = true;
        }
Exemplo n.º 26
0
        /// <summary>
        /// Fetch ItemList.
        /// </summary>
        /// <param name="criteria">The criteria.</param>
        /// <returns></returns>
        public ItemList Fetch(ItemCriteria criteria)
        {
            ItemList item = (ItemList)Activator.CreateInstance(typeof(ItemList), true);

            bool cancel = false;

            OnFetching(criteria, ref cancel);
            if (cancel)
            {
                return(item);
            }

            // Fetch Child objects.
            using (var connection = new SqlConnection(ADOHelper.ConnectionString))
            {
                connection.Open();
                using (var command = new SqlCommand("[dbo].[CSLA_Item_Select]", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddRange(ADOHelper.SqlParameters(criteria.StateBag));
                    command.Parameters.AddWithValue("@p_ListPriceHasValue", criteria.ListPriceHasValue);
                    command.Parameters.AddWithValue("@p_UnitCostHasValue", criteria.UnitCostHasValue);
                    command.Parameters.AddWithValue("@p_SupplierHasValue", criteria.SupplierHasValue);
                    command.Parameters.AddWithValue("@p_StatusHasValue", criteria.StatusHasValue);
                    command.Parameters.AddWithValue("@p_NameHasValue", criteria.NameHasValue);
                    command.Parameters.AddWithValue("@p_ImageHasValue", criteria.ImageHasValue);
                    using (var reader = new SafeDataReader(command.ExecuteReader()))
                    {
                        if (reader.Read())
                        {
                            do
                            {
                                item.Add(new ItemFactory().Map(reader));
                            } while(reader.Read());
                        }
                    }
                }
            }

            MarkOld(item);
            MarkAsChild(item);
            OnFetched();
            return(item);
        }
Exemplo n.º 27
0
        //数据查询
        private void button_inquery_Click(object sender, EventArgs e)
        {
            string str = "#col like '%#value%' ";

            if (comboBox_queryCol.SelectedIndex == 0)
            {
                str = str.Replace("#col", "采集人编号").Replace("#value", textBox_QueryKey.Text);
            }
            else if (comboBox_queryCol.SelectedIndex == 1)
            {
                str = str.Replace("#col", "上传人编号").Replace("#value", textBox_QueryKey.Text);
            }
            else if (comboBox_queryCol.SelectedIndex == 2)
            {
                str = "上传时间 >= '#date1' and 上传时间<= '#date2' ";
                str = str.Replace("#date1", dateTimePicker1.Text).Replace("#date2", dateTimePicker2.Text);
            }
            else if (comboBox_queryCol.SelectedIndex == 3)
            {
                str = str.Replace("#col", "上传标题").Replace("#value", textBox_QueryKey.Text);
            }
            else
            {
                str = str.Replace("#col", "上传备注").Replace("#value", textBox_QueryKey.Text);
            }

            string strQuery = @" select  ID as 编号, uid1 as 采集人编号, uid2 as 上传人编号, uploadTime as 上传时间, uploadTitle as 上传标题,
                                 uploadDes as 上传备注, createTime as 采集时间, fileDir as 保存路径 
                                 from fileUpload order by ID DESC";

            ADOHelper db = new ADOHelper();

            DataView dvNewDataViewObject = new DataView();

            dvNewDataViewObject.Table     = db.ExecuteGet(strQuery).Tables[0];
            dvNewDataViewObject.RowFilter = str;
            //dview_UploadInfo.DataBindings.Clear();
            //dview_UploadInfo.DataSource = dvNewDataViewObject;
            srcTable = dvNewDataViewObject.ToTable();
            ChangeDataSoure(srcTable);
            InitPageSet(20);
            imageButton_first.PerformClick();//默认先显示第一页
        }
Exemplo n.º 28
0
        private bool checkLogin()
        {
            //防止sql注入 类似 where user='******' and pwd ='123' or 'a' = 'a'
            if (textBox_uname.Text.IndexOf(" ") > 0 || textBox_upwd.Text.IndexOf(" ") > 0)
            {
                return(false);
            }

            //ADOHelper db = new ADOHelper();

            string str = m_strLoginStr;

            str = str.Replace("#username", textBox_uname.Text);
            str = str.Replace("#pwd", textBox_upwd.Text);

            try
            {
                ADOHelper       db     = new ADOHelper();
                OleDbDataReader result = db.ExecuteRead(str);
                if (!result.HasRows)
                {
                    return(false);
                }

                while (result.Read())//保存全局用户信息
                {
                    ClassGlobalUserInfo.cName      = result["cName"].ToString();
                    ClassGlobalUserInfo.amdName    = result["AdmName"].ToString();
                    ClassGlobalUserInfo.userNumber = result["userNumber"].ToString();
                    ClassGlobalUserInfo.roleID     = result["roleID"].ToString();
                    ClassGlobalUserInfo.depId      = result["depId"].ToString();
                    ClassGlobalUserInfo.depCId     = result["depCId"].ToString();
                }
            }
            catch (Exception se)
            {
                CValidateTools.showError(se.ToString());
                return(false);
            }


            return(true);
        }
Exemplo n.º 29
0
 public List <Event> GetEvents()
 {
     try
     {
         using (SqlConnection con = new SqlConnection(connectionString))
         {
             SqlCommand com = new SqlCommand();
             com.Connection  = con;
             com.CommandText = @"select TextID, Fixtext from cFixText where ApplID=6 and LanguageFK='RUS' ";
             var sqlDataReader = com.ExecuteReader();
             return(ADOHelper.MapAll <Event>(sqlDataReader));
         }
     }
     catch (Exception ex)
     {
         logger.Log("GetEvents", ex);
         return(new List <Event>());
     }
 }
Exemplo n.º 30
0
    private void SelectMaxValue()
    {
        int           id;
        ADOHelper     obj = new ADOHelper();
        SqlDataReader dr  = obj.GetDataReader("SELECT MAX(TutorialID) as TutorialID FROM tblTutorial");



        if (dr["TutorialID"] != DBNull.Value)
        {
            id = int.Parse(dr["TutorialID"].ToString()) + 1;
            txtTutorialID.Text = id.ToString();
        }
        else
        {
            id = 1;
            txtTutorialID.Text = id.ToString();
        }
    }