示例#1
0
        static void PopulateTerms(List <AyurvedicDictionaryTerm> terms)
        {
            // In this sample, we use a local database (MS Access) for demo purposes, because
            // it is easy to deploy.
            // You can use the Entity Framework or other ORM (Object-Relational Mapping) technology
            // to retrieve all items (Terms) from a data table.
            AccessDataSource ds = new AccessDataSource();

            ds.DataFile      = NiaMdbFilePath;
            ds.SelectCommand = "SELECT * FROM [Terms] ORDER BY [DEVANAGARI]";
            IEnumerable data = ds.Select(new DataSourceSelectArguments());

            if (data is DataView)
            {
                DataView dataView = data as DataView;
                for (int i = 0; i < dataView.Count; i++)
                {
                    AyurvedicDictionaryTerm item = new AyurvedicDictionaryTerm();
                    item.Id           = (int)dataView[i]["ID"];
                    item.Devanagari   = (string)dataView[i]["DEVANAGARI"];
                    item.IAST         = (string)dataView[i]["IAST"];
                    item.HarvardKyoto = (string)dataView[i]["HarvardKyoto"];
                    item.EnglishText  = (string)dataView[i]["ENGLISH"];
                    terms.Add(item);
                }
            }
        }
    private bool validataemmailid()
    {
        string emailid = email_txt.Text.Substring(email_txt.Text.IndexOf("@") + 1);

        DataTable        myTable = new DataTable();
        AccessDataSource AD      = new AccessDataSource("~/gensym_accounts.mdb", "SELECT [company] AS [company], [valid] AS [valid]FROM useraccounts ORDER BY [company] DESC");
        DataView         dv      = (DataView)AD.Select(DataSourceSelectArguments.Empty);

        myTable = dv.ToTable();

        string companyname;

        for (int i = 0; i < myTable.Rows.Count; i++)
        {
            companyname = myTable.Rows[i]["company"].ToString();
            if (emailid.Trim().ToUpper().Contains(companyname.Trim().ToUpper().ToString()))
            {
                if (myTable.Rows[i]["valid"].ToString() == "True")
                {
                    return(true);
                }
                else
                {
                    HttpCookie str = new HttpCookie("errorstring", "THIS EMAIL ID IS CURRENTLY NOT ALLOWED BY INSTANT TEMP, PLEASE CONTACT US FOR MORE INFORMATION ");
                    Response.Cookies.Add(str);

                    return(false);
                }
            }
        }
        AD.InsertCommand = "INSERT INTO useraccounts(emailid, [password], company, valid) VALUES ('" + email_txt.Text + "',' ','" + emailid.Trim() + "',0)";
        AD.Insert();

        return(true);
    }
    public void BindGuideCourseGridView()
    {
        int guideCode = -1;

        if (Session["LoggedInGuideCode"] != null)
        {
            guideCode = (int)Session["LoggedInGuideCode"];
        }

        AccessDataSource DS = new AccessDataSource();

        DS.DataFile = "~/App_Data/Matnas_Database.accdb";

        DS.SelectCommand = @"SELECT Courses.CourseName, Rooms.RoomName, WorkingDays.Name, WorkingHours.HourName
                            FROM (((((TimeTable INNER JOIN
                         Rooms ON TimeTable.RoomCode = Rooms.RoomCode) INNER JOIN
                         WorkingDays ON TimeTable.[Day] = WorkingDays.DayCode) INNER JOIN
                         WorkingHours ON TimeTable.[Hour] = WorkingHours.HourCode) INNER JOIN
                         GuidesInCourses ON TimeTable.GuideCourseCode = GuidesInCourses.GuideCourseCode) INNER JOIN
                         Courses ON GuidesInCourses.CourseCode = Courses.CourseCode)
                         WHERE GuidesInCourses.GuideCode = " + guideCode + "";

        GridViewGuides.DataSource = DS;
        GridViewGuides.DataBind();

        if (GridViewGuides.Rows.Count > 0)
        {
            GridViewGuides.HeaderRow.Cells[0].Text = "Course Name";
            GridViewGuides.HeaderRow.Cells[1].Text = "Room name";
            GridViewGuides.HeaderRow.Cells[2].Text = "Day";
            GridViewGuides.HeaderRow.Cells[3].Text = "Hour";
        }
    }
示例#4
0
    protected void login_btn_Click(object sender, EventArgs e)
    {
        DataTable        accountstable = new DataTable();
        AccessDataSource AD            = new AccessDataSource("~/gensym_accounts.mdb", "SELECT username,password FROM admin_accounts WHERE ((username = ?) AND (password = ?))");

        AD.SelectParameters.Add("username", username_txt.Text);
        AD.SelectParameters.Add("password", password_txt.Text);
        DataView dv = (DataView)AD.Select(DataSourceSelectArguments.Empty);

        accountstable = dv.ToTable();

        if (accountstable.Rows.Count == 1)
        {
            content.Visible   = true;
            login_div.Visible = false;
            string     sec_cook = FormsAuthentication.HashPasswordForStoringInConfigFile(password_txt.Text, "sha1");
            HttpCookie sec      = new HttpCookie("val", sec_cook);
            sec.Expires = DateTime.Now.AddHours(2);
            Response.Cookies.Set(sec);
        }
        else
        {
            content.Visible = false;
            Response.Cookies["val"].Expires = DateTime.Now.AddHours(-1);
            error_lbl.Text = "INVALID USERNAME AND PASSWORD";
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        AccessDataSource vd3 = new AccessDataSource();

        vd3.DataFile          = Server.MapPath(".") + "//App_Data/db1.mdb";
        vd3.SelectCommandType = SqlDataSourceCommandType.Text;
        vd3.SelectCommand     = "Select * from chuyenbay where noidi=@noidi and noiden=@noiden and ngaydi=@ngaydi";
        vd3.SelectParameters.Add("noidi", TypeCode.String, DropDownList1.SelectedItem.Value.ToString());
        vd3.SelectParameters.Add("noiden", TypeCode.String, DropDownList2.SelectedItem.Value.ToString());
        vd3.SelectParameters.Add("ngaydi", TypeCode.String, Calendar1.SelectedDate.DayOfWeek.ToString());
        GridView1.DataSource = vd3;
        GridView1.DataBind();


        if (RadioButtonList1.SelectedValue == "khuhoi")
        {
            AccessDataSource vd2 = new AccessDataSource();
            vd2.DataFile          = Server.MapPath(".") + "//App_Data/db1.mdb";
            vd2.SelectCommandType = SqlDataSourceCommandType.Text;
            vd2.SelectCommand     = "Select * from chuyenbay where noidi=@noidi and noiden=@noiden and ngaydi=@ngaydi";
            vd2.SelectParameters.Add("noidi", TypeCode.String, DropDownList2.SelectedItem.Value.ToString());
            vd2.SelectParameters.Add("noiden", TypeCode.String, DropDownList1.SelectedItem.Value.ToString());
            vd2.SelectParameters.Add("ngaydi", TypeCode.String, Calendar2.SelectedDate.DayOfWeek.ToString());
            GridView2.DataSource = vd2;
            GridView2.DataBind();
        }
    }
        /// <summary>
        /// Initializes a new instance of the <see cref="AccessTransactionalDataSource"/> class.
        /// </summary>
        /// <param name="dataSource">The data source.</param>
        /// <param name="isolationLevel">The isolation level.</param>
        /// <param name="forwardEvents">if set to <c>true</c> [forward events].</param>
        public AccessTransactionalDataSource(AccessDataSource dataSource, IsolationLevel?isolationLevel, bool forwardEvents) : base(new AccessDataSourceSettings() { DefaultCommandTimeout = dataSource.DefaultCommandTimeout, StrictMode = dataSource.StrictMode, SuppressGlobalEvents = dataSource.SuppressGlobalEvents || forwardEvents })
        {
            if (dataSource == null)
            {
                throw new ArgumentNullException(nameof(dataSource), $"{nameof(dataSource)} is null.");
            }

            Name = dataSource.Name;

            m_BaseDataSource = dataSource;
            m_Connection     = dataSource.CreateConnection();

            if (isolationLevel == null)
            {
                m_Transaction = m_Connection.BeginTransaction();
            }
            else
            {
                m_Transaction = m_Connection.BeginTransaction(isolationLevel.Value);
            }

            if (forwardEvents)
            {
                ExecutionStarted  += (sender, e) => dataSource.OnExecutionStarted(e);
                ExecutionFinished += (sender, e) => dataSource.OnExecutionFinished(e);
                ExecutionError    += (sender, e) => dataSource.OnExecutionError(e);
                ExecutionCanceled += (sender, e) => dataSource.OnExecutionCanceled(e);
            }

            AuditRules = dataSource.AuditRules;
            UserValue  = dataSource.UserValue;
        }
    public static void SaveDocument(DocObj doc)
    {
        using (AccessDataSource dataSource = new AccessDataSource("~/App_Data/Reader.mdb", "")) {
            dataSource.UpdateCommand = String.Format(@"

                   UPDATE 
                        [Documents]
                       
                   SET 
                        [Documents].[Author] = @Author,
                        [Documents].[Title] = @Title,
                        [Documents].[Chapter] = @Chapter,
                        [Documents].[Body] = @Body,
                        [Documents].[Book] = @Book,
                        [Documents].[_Year] = @_Year
                
                    WHERE [Documents].[Id] = {{guid {0}}} 

                ", doc.Id.ToString("B"));

            dataSource.UpdateParameters.Add("Author", DbType.String, doc.Author);
            dataSource.UpdateParameters.Add("Title", DbType.String, doc.Title);
            dataSource.UpdateParameters.Add("Chapter", DbType.String, doc.Chapter);
            dataSource.UpdateParameters.Add("Body", DbType.String, doc.Content);
            dataSource.UpdateParameters.Add("Book", DbType.String, doc.Book);
            dataSource.UpdateParameters.Add("_Year", DbType.String, doc.Year);

            dataSource.Update();
        }
    }
示例#8
0
    protected void LinkButton5_Click(object sender, EventArgs e)
    {
        CheckBox         chkbox = new CheckBox();
        AccessDataSource ads    = new AccessDataSource();

        ads.DataFile = "~/APP_Data/mystore.mdb";

        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            chkbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
            if (chkbox.Checked)
            {
                ads.InsertCommand = "insert into temp(cartCustomer,ProductID,ProductName,UnitPrice,Quantity) values(?,?,?,?,?)";
                //string cn = Session["cartName"].ToString();

                //string pid = GridView1.Rows[i].Cells[1].Text;
                //string pn = GridView1.Rows[i].Cells[2].Text;
                //string up =((Label)GridView1.Rows[i].FindControl("unitPrice")).Text;
                ads.InsertParameters.Clear();
                ads.InsertParameters.Add("cartCustomer", Session["cartName"].ToString());
                ads.InsertParameters.Add("ProductID", GridView1.Rows[i].Cells[1].Text);
                ads.InsertParameters.Add("ProductName", GridView1.Rows[i].Cells[2].Text);
                ads.InsertParameters.Add("UnitPrice", ((Label)GridView1.Rows[i].FindControl("Label2")).Text);
                ads.InsertParameters.Add("Quantity", GridView1.Rows[i].Cells[4].Text);
                ads.Insert();
            }
        }
        ads.Dispose();
        Response.Redirect("finishOrd.aspx");
    }
示例#9
0
        public void SelectFromAccessDataSourceControlSearch()
        {
            SelectFromAccessDataSourceControl();
            Grid grid = new Grid();


            SetupGrid(grid);

            AccessDataSource ds = new AccessDataSource();

            ds.SelectCommand = "select * from Employees";
            ds.ID            = "test1";
            ds.DataFile      = Path + "\\App_Data\\Nwind.mdb";
            Testpage.Controls.Add(ds);
            grid.DataSourceId = ds.ID;
            grid.Search       = "ol -olav";

            StringBuilder  sb         = new StringBuilder();
            StringWriter   sw         = new StringWriter(sb);
            HtmlTextWriter gridwriter = new HtmlTextWriter(sw);

            grid.RenderControl(gridwriter);

            Assert.Less(grid.MasterTable.Rows.Count, employees);
        }
示例#10
0
        static void Main(string[] args)
        {
            var settings = Settings.Default;

            var ds = new AccessDataSource(settings.DatabaseConnectionString);

            ds.TestConnection();

            //Connection strings:
            //https://www.connectionstrings.com/access/

            //If you see The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine
            //https://www.connectionstrings.com/the-microsoft-ace-oledb-12-0-provider-is-not-registered-on-the-local-machine/
            //This didn't work for me. I can only open MDB files, not accdb files.
            //Fortunately it is easy to change the type using Save As in Access.

            var filter  = new { EmailSent = false }; //This could also be a SQL WHERE string
            var newRows = ds.From <Table1>(filter).ToCollection().Execute();

            if (newRows.Count > 0)
            {
                using (var emailClient = new SmtpClient())
                {
                    emailClient.Connect(settings.SmtpServer, settings.SmtpPort, SecureSocketOptions.Auto);

                    //Remove any OAuth functionality as we won't be using it.
                    emailClient.AuthenticationMechanisms.Remove("XOAUTH2");

                    emailClient.Authenticate(settings.SmtpUsername, settings.SmtpPassword);

                    foreach (var row in newRows)
                    {
                        //Create and send the message
                        var message = new MimeMessage();
                        message.To.Add(new MailboxAddress(settings.ToAddress));
                        message.From.Add(new MailboxAddress(settings.FromAddress));

                        message.Subject = "This is a test for record " + row.Id;

                        //We will say we are sending HTML. But there are options for plaintext etc.
                        message.Body = new TextPart(TextFormat.Html)
                        {
                            Text = "Hello " + row.Name
                        };
                        emailClient.Send(message);
                        Console.WriteLine("Send email for " + row.Id);

                        //Update the database
                        row.EmailSent = true;
                        ds.Update(row).Execute();
                    }

                    emailClient.Disconnect(true);
                }
            }
            else
            {
                Console.WriteLine("No new rows");
            }
        }
示例#11
0
        /// <summary>
        /// 单DML语句操作
        /// </summary>
        /// <param name="id">SQL语句ID编号</param>
        /// <param name="obj">输入输出对象</param>
        /// <returns></returns>
        public string execDml(string id, Object obj)
        {
            resultSql = "";
            if (id == "")
            {
                throw new Exception("参数不全");
            }
            if (obj == null)
            {
                throw new Exception("参数不全");
            }
            daoStruct = parseDao.ObtainConfig(id);
            if (daoStruct.DbType.Length <= 0 || daoStruct.ConStr.Length <= 0 || daoStruct.SqlStr.Length <= 0)
            {
                throw new Exception("配置参数不全");
            }
            string sql = "";

            sql       = setSql(obj, daoStruct.SqlStr);
            resultSql = sql;
            //记录SQL
            if (daoStruct.IsLog)
            {
                WriteLogin.writeDBLog(daoStruct.Desc, resultSql);
            }
            if (sql.Length <= 0)
            {
                throw new Exception("构造SQL语句出错");
            }
            IDataSource dataSource = null;

            switch (daoStruct.DbType)
            {
            case "oracle":
                dataSource = new OracleDataSource(daoStruct);
                break;

            case "mysql":
                dataSource = new MySqlDataSource(daoStruct);
                break;

            case "sql":
                dataSource = new SqlDataSource(daoStruct);
                break;

            case "access":
                dataSource = new AccessDataSource(daoStruct);
                break;

            case "sqllite":
                dataSource = new SqlLiteDataSource(daoStruct);
                break;
            }
            if (dataSource != null)
            {
                dataSource.SingleExecute(sql);
            }

            return("");
        }
示例#12
0
        /// <summary>
        /// Prepare DML
        /// </summary>
        /// <param name="ids">SQL语句ID编号</param>
        /// <param name="objs">输入对象</param>
        /// <returns></returns>
        public string execPrepare(string id, Object obj)
        {
            try
            {
                resultSql = "";
                if (id == null)
                {
                    throw new Exception("参数不全");
                }
                if (obj == null)
                {
                    throw new Exception("参数不全");
                }
                daoStruct = parseDao.ObtainConfig(id);
                if (daoStruct.DbType.Length <= 0 || daoStruct.ConStr.Length <= 0 || daoStruct.SqlStr.Length <= 0)
                {
                    throw new Exception("配置参数不全");
                }
                string sql = daoStruct.SqlStr;
                resultSql = sql;
                if (daoStruct.IsLog)
                {
                    WriteLogin.writeDBLog(daoStruct.Desc, sql);
                }
                List <DTOClass> dtolist = setDto(obj);
                if (sql.Length <= 0)
                {
                    throw new Exception("构造SQL语句出错");
                }
                IDataSource dataSource = null;
                switch (daoStruct.DbType)
                {
                case "oracle":
                    dataSource = new OracleDataSource(daoStruct);
                    break;

                case "mysql":
                    dataSource = new MySqlDataSource(daoStruct);
                    break;

                case "sql":
                    dataSource = new SqlDataSource(daoStruct);
                    break;

                case "access":
                    dataSource = new AccessDataSource(daoStruct);
                    break;

                case "sqllite":
                    dataSource = new SqlLiteDataSource(daoStruct);
                    break;
                }
                dataSource.PrepareExcute(sql, dtolist);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            return("");
        }
        protected override void OnLoad(EventArgs e) {
            base.OnLoad(e);

            // Initializes a data source.
            ds = new AccessDataSource("~/nwind.mdb", "SELECT [CategoryName]," +
                "[ProductName], [ProductSales], [ShippedDate] FROM [ProductReports]");

            // Initializes ASPxPivotGrid.
            ASPxPivotGrid1 = new ASPxPivotGrid();

            // Binds ASPxPivotGrid to the data source.
            ASPxPivotGrid1.DataSource = ds;
            
            // Places the Pivot Grid onto a page.
            form1.Controls.Add(ASPxPivotGrid1);

            if (ASPxPivotGrid1.Fields.Count != 0) 
                return;

            // Creates pivot grid fields for all data source fields.
            ASPxPivotGrid1.RetrieveFields();

            // Locates the pivot grid fields in appropriate areas.
            ASPxPivotGrid1.Fields["CategoryName"].Area = PivotArea.RowArea;
            ASPxPivotGrid1.Fields["ProductName"].Area = PivotArea.RowArea;
            ASPxPivotGrid1.Fields["ShippedDate"].Area = PivotArea.ColumnArea;
            ASPxPivotGrid1.Fields["ProductSales"].Area = PivotArea.DataArea;

            ASPxPivotGrid1.Fields["ShippedDate"].GroupInterval = PivotGroupInterval.DateYear;
        }
 public void ProvideRowInsertion(ASPxScheduler control, AccessDataSource dataSource)
 {
     dataSource.Inserted             += new SqlDataSourceStatusEventHandler(AppointmentsDataSource_Inserted);
     control.AppointmentRowInserting += new ASPxSchedulerDataInsertingEventHandler(ControlOnAppointmentRowInserting);
     control.AppointmentRowInserted  += new ASPxSchedulerDataInsertedEventHandler(ControlOnAppointmentRowInserted);
     control.AppointmentsInserted    += new PersistentObjectsEventHandler(ControlOnAppointmentsInserted);
 }
    protected void dsProducts_Init(object sender, EventArgs e)
    {
        AccessDataSource dataSource = sender as AccessDataSource;
        GridViewDetailRowTemplateContainer container = dataSource.NamingContainer as GridViewDetailRowTemplateContainer;

        dataSource.SelectParameters["CategoryID"].DefaultValue = container.KeyValue.ToString();
    }
    public static DocObj GetDocument(Guid id)
    {
        using (AccessDataSource dataSource = new AccessDataSource("~/App_Data/Reader.mdb", "")) {
            dataSource.SelectCommand = String.Format(@"
            
                SELECT * 
                                
                        FROM [Documents]

                WHERE [Documents].[Id] = {{guid {0}}}", id.ToString("B"));

            dataSource.SelectParameters.Add("Id", DbType.Guid, id.ToString());

            DataView view = (DataView)dataSource.Select(DataSourceSelectArguments.Empty);

            if (view.Count > 0)
            {
                return(new DocObj()
                {
                    Id = (Guid)(view.Table.Rows[0]["Id"]),
                    Author = Convert.ToString(view.Table.Rows[0]["Author"]),
                    Book = Convert.ToString(view.Table.Rows[0]["Book"]),
                    Content = Convert.ToString(view.Table.Rows[0]["Body"]),
                    Title = Convert.ToString(view.Table.Rows[0]["Title"]),
                    Chapter = Convert.ToString(view.Table.Rows[0]["Chapter"]),
                    Year = Convert.ToString(view.Table.Rows[0]["_Year"]),
                });
            }
        }

        return(null);
    }
        /// <summary>
        /// Initializes a new instance of the <see cref="AccessTransactionalDataSource" /> class.
        /// </summary>
        /// <param name="dataSource">The data source.</param>
        /// <param name="forwardEvents">if set to <c>true</c> [forward events].</param>
        /// <param name="connection">The connection.</param>
        /// <param name="transaction">The transaction.</param>
        /// <exception cref="System.ArgumentNullException">
        /// </exception>
        internal AccessTransactionalDataSource(AccessDataSource dataSource, bool forwardEvents, OleDbConnection connection, OleDbTransaction transaction) : base(new AccessDataSourceSettings() { DefaultCommandTimeout = dataSource.DefaultCommandTimeout, StrictMode = dataSource.StrictMode, SuppressGlobalEvents = dataSource.SuppressGlobalEvents || forwardEvents })
        {
            if (dataSource == null)
            {
                throw new ArgumentNullException(nameof(dataSource), $"{nameof(dataSource)} is null.");
            }
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection), $"{nameof(connection)} is null.");
            }
            if (transaction == null)
            {
                throw new ArgumentNullException(nameof(transaction), $"{nameof(transaction)} is null.");
            }

            Name = dataSource.Name;

            m_BaseDataSource = dataSource;
            m_Connection     = connection;
            m_Transaction    = transaction;

            if (forwardEvents)
            {
                ExecutionStarted  += (sender, e) => dataSource.OnExecutionStarted(e);
                ExecutionFinished += (sender, e) => dataSource.OnExecutionFinished(e);
                ExecutionError    += (sender, e) => dataSource.OnExecutionError(e);
                ExecutionCanceled += (sender, e) => dataSource.OnExecutionCanceled(e);
            }

            AuditRules = dataSource.AuditRules;
            UserValue  = dataSource.UserValue;
        }
示例#18
0
    void cmbChild_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
    {
        ASPxComboBox     cmbChild = (ASPxComboBox)sender;
        AccessDataSource cmbChildAccessDataSource = (AccessDataSource)cmbChild.NamingContainer.FindControl("asdChild");

        cmbChildAccessDataSource.SelectParameters[0].DefaultValue = e.Parameter;
        cmbChild.DataBindItems();
    }
 public AccessDataSourceConnectionChooserPanel(AccessDataSourceDesigner accessDataSourceDesigner, AccessDataSource accessDataSource) : base(accessDataSourceDesigner)
 {
     this._accessDataSource         = accessDataSource;
     this._accessDataSourceDesigner = accessDataSourceDesigner;
     this.InitializeComponent();
     this.InitializeUI();
     this.DataFile = this._accessDataSource.DataFile;
 }
    private void InitializeDataSuorce()
    {
        string       path    = Server.MapPath("~/App_Data/NorthWind.mdb");
        const string command = "SELECT * FROM [Products]";

        ads            = new AccessDataSource(path, command);
        ads.Selecting += ads_Selecting;
    }
示例#21
0
 private void Insert(OrderedDictionary newValues, AccessDataSource datasource)
 {
     foreach (var item in newValues.Keys)
     {
         datasource.InsertParameters[(string)item].DefaultValue = Convert.ToString(newValues[item]);
     }
     datasource.Insert();
 }
示例#22
0
    protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
    {
        AccessDataSource ads = new AccessDataSource();

        ads.DataFile      = "~/date/blog_Data.mdb";
        ads.SelectCommand = "SELECT * FROM blogCategory ";
        DataView dv = (DataView)ads.Select(DataSourceSelectArguments.Empty);
    }
示例#23
0
        private static int GetCategoryId()
        {
            AccessDataSource ds = new AccessDataSource();

            ds.SelectCommand = "SELECT TOP 1 CategoryID FROM Categories ORDER BY CategoryID DESC";
            ds.ID            = "test1";
            ds.DataFile      = Path + "\\App_Data\\Nwind.mdb";
            return((int)((DataView)ds.Select(DataSourceSelectArguments.Empty))[0]["CategoryID"]);
        }
示例#24
0
 private void Update(OrderedDictionary keys, OrderedDictionary newValues, AccessDataSource datasource)
 {
     foreach (var item in newValues.Keys)
     {
         datasource.UpdateParameters[(string)item].DefaultValue = Convert.ToString(newValues[item]);
     }
     datasource.UpdateParameters[nwd2.UpdateParameters.Count - 1].DefaultValue = Convert.ToString(keys[0]);
     datasource.Update();
 }
        public static IEnumerable GetAllEmployees()
        {
            AccessDataSource ads = new AccessDataSource();

            ads.DataSourceMode = SqlDataSourceMode.DataReader;
            ads.DataFile       = "~//App_Data//Northwind.mdb";
            ads.SelectCommand  = "SELECT EmployeeID,FirstName,LastName FROM Employees";
            return(ads.Select(DataSourceSelectArguments.Empty));
        }
示例#26
0
 private void PopualData()
 {
     using (AccessDataSource dc = new AccessDataSource())
     {
         var v = dc.NameDatas.OrderBy(a => a.Adress).ThenBy(a => a.Bill).ThenBy(a => Date).ThenBy(a => Branch).ThenBy(a => agent).ToList();
         gvData.DataSoure = v;
         gvData.DataBind();
     }
 }
示例#27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AccessDataSource vd3 = new AccessDataSource();

        vd3.DataFile          = Server.MapPath(".") + "//App_Data/db1.mdb";
        vd3.SelectCommandType = SqlDataSourceCommandType.Text;
        vd3.SelectCommand     = "Select * from chuyenbay";
        GridView1.DataSource  = vd3;
        GridView1.DataBind();
    }
示例#28
0
        public AccessDataSource AttachSoftDeleteRulesWithUser(AccessDataSource source)
        {
            var currentUser1 = source.From(EmployeeTableName).WithLimits(1).ToObject <Employee>().Execute();

            return(source.WithRules(
                       new SoftDeleteRule("DeletedFlag", true, OperationTypes.SelectOrDelete),
                       new UserDataRule("DeletedByKey", "EmployeeKey", OperationTypes.Delete),
                       new DateTimeRule("DeletedDate", DateTimeKind.Local, OperationTypes.Delete)
                       ).WithUser(currentUser1));
        }
示例#29
0
 public AccessDataSource AttachRules(AccessDataSource source)
 {
     return(source.WithRules(
                new DateTimeRule("CreatedDate", DateTimeKind.Local, OperationTypes.Insert),
                new DateTimeRule("UpdatedDate", DateTimeKind.Local, OperationTypes.InsertOrUpdate),
                new UserDataRule("CreatedByKey", "EmployeeKey", OperationTypes.Insert),
                new UserDataRule("UpdatedByKey", "EmployeeKey", OperationTypes.InsertOrUpdate),
                new ValidateWithValidatable(OperationTypes.InsertOrUpdate)
                ));
 }
示例#30
0
    protected void DataListDataBind()
    {
        AccessDataSource ads = new AccessDataSource();

        ads.DataFile = "~/App_Data/mystore.mdb";
        //Sql_StringChar sql_String = new Sql_StringChar();//动态数据源
        //sql_String.ConnectionString = sql_String.sql_char;//连接字符串
        GetCa_id();
        ads.SelectCommand = "SELECT * FROM [Product] where ca_id=" + ca_id + " ";
        DataView        dv      = (DataView)ads.Select(DataSourceSelectArguments.Empty);
        PagedDataSource objPage = new PagedDataSource();

        objPage.DataSource  = dv;
        objPage.AllowPaging = true;
        objPage.PageSize    = 3;
        int TolPage;

        TolPage = objPage.PageCount;
        int CurPage;

        if (Request.QueryString["Page"] != null)
        {
            CurPage = Convert.ToInt32(Request.QueryString["Page"]);
        }
        else
        {
            CurPage = 1;
        }
        objPage.CurrentPageIndex = CurPage - 1;
        //pagenum.Text = CurPage.ToString();
        //pagecount.Text = objPage.PageCount + "";
        lnkFirst.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1" + "&PageSize=" + Convert.ToString(objPage.PageSize);
        lnkLast.NavigateUrl  = Request.CurrentExecutionFilePath + "?Page=" + TolPage.ToString() + "&PageSize=" + Convert.ToString(objPage.PageSize);
        if (!objPage.IsFirstPage)
        {
            lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1) + "&PageSize=" + Convert.ToString(objPage.PageSize);
        }
        else
        {
            lnkPrev.Visible  = false;
            lnkFirst.Visible = false;
        }
        if (!objPage.IsLastPage)
        {
            lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1) + "&PageSize=" + Convert.ToString(objPage.PageSize);
        }
        else
        {
            lnkNext.Visible = false;
            lnkLast.Visible = false;
        }

        DataList1.DataSource = objPage;
        DataList1.DataBind();
    }
示例#31
0
    protected void LoginButton_Click(object sender, EventArgs e)
    {
        AccessDataSource ads = new AccessDataSource();
        ads.DataFile = "~/App_Data/Xalsa.mdb";

        if (this.Username.Text.Length == 0 | this.Password.Text.Length == 0)
        {
            this.Label1.ForeColor = System.Drawing.Color.Red;
            this.Label1.Text = "Login failed!";
            this.Username.Text = "";
            this.Password.Text = "";
            return;
        }

        ads.SelectParameters.Add("Username", this.Username.Text);
        ads.SelectParameters.Add("Password", this.Password.Text);

        ads.SelectCommand = "SELECT * FROM [Login] WHERE [Username] = @Username AND [Password] = @Password";

        DataView dv = (DataView)ads.Select(DataSourceSelectArguments.Empty);

        if (dv.Count == 0)
        {
            this.Label1.ForeColor = System.Drawing.Color.Red;
            this.Label1.Text = "Account details does not exist. Please register.";
            this.Username.Text = "";
            this.Password.Text = "";
            return;
        }

        this.Session["Username"] = dv[0].Row["Username"].ToString();
        this.Session["UserType"] = dv[0].Row["UserType"].ToString();

        if (this.Session["UserType"].ToString().Equals("member"))
            Response.Redirect("MembersHome.aspx");
        else if (this.Session["UserType"].ToString().Equals("admin"))
            Response.Redirect("AdminHome.aspx");
    }
	// Constructors
	public AccessDataSourceView(AccessDataSource owner, string name, System.Web.HttpContext context) {}
示例#33
0
文件: DB.cs 项目: EgyFalseX/WebSites
    public static AccessDataSource GetSqlCommandString(DBTablesNames TableName)
    {
        AccessDataSource ADS = new AccessDataSource();
        DataTable dt = new DataTable();
        ADS.DataFile = AATSWEBPath;
        switch (TableName)
        {
            case DBTablesNames.TBLTrainee:
                ADS.SelectCommand = "SELECT TraineeID, TraineeName, NameInEnglish, NationalityId, Mobile, tel, Email, City, Address, mony, accname, countryId, TimeIn FROM TBLTrainee";
                ADS.InsertCommand = @"INSERT INTO TBLTrainee (TraineeID, TraineeName, NameInEnglish, NationalityId, Mobile, tel, Email, City, Address, mony, accname, countryId, TimeIn)
                                    VALUES (@TraineeID, @TraineeName, @NameInEnglish, @NationalityId, @Mobile, @tel, @Email, @City, @Address, @mony, @accname, @countryId, NOW())";
                ADS.UpdateCommand = @"UPDATE TBLTrainee SET TraineeName = @TraineeName, NameInEnglish = @NameInEnglish, NationalityId = @NationalityId, Mobile = @Mobile,
                                    tel = @tel, Email = @Email, City = @City, Address = @Address, mony = @mony, accname = @accname, countryId = @countryId, TimeIn = NOW()
                                    Where TraineeID = @TraineeID";
                ADS.DeleteCommand = @"DELETE FROM TBLTrainee WHERE (TraineeID = @TraineeID)";

                //string xxx = ADS.InsertParameters.Count.ToString();
                //dt = LoadTableAATSWEB(ADS.SelectCommand);
                break;
            case DBTablesNames.Cdcountry:
                ADS.SelectCommand = "Select countryId, country From Cdcountry";
                ADS.InsertCommand = "";
                ADS.UpdateCommand = "";
                ADS.DeleteCommand = "";
                break;

            case DBTablesNames.CdNationality:
                ADS.SelectCommand = "Select NationalityId, Nationality From CdNationality";
                ADS.InsertCommand = "";
                ADS.UpdateCommand = "";
                ADS.DeleteCommand = "";
                break;
            default:
                break;
        }
        OleDbConnection con = ConnectionAATSWEB;
        con.Open();
        dt = con.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new object[] { null, null, TableName.ToString(), null });
        foreach (DataRow row in dt.Rows)
        {
            //(int)row["DATA_TYPE"]
            int datatype = Convert.ToInt16(row["DATA_TYPE"]);
            ADS.InsertParameters.Add(row["COLUMN_NAME"].ToString(), ColumnType(datatype), "");
            ADS.UpdateParameters.Add(row["COLUMN_NAME"].ToString(), ColumnType(datatype), "");
            ADS.DeleteParameters.Add(row["COLUMN_NAME"].ToString(), ColumnType(datatype), "");
        }

        return ADS;
    }