当前位置: 首页>>代码示例>>C#>>正文


C# DataClassesDataContext类代码示例

本文整理汇总了C#中DataClassesDataContext的典型用法代码示例。如果您正苦于以下问题:C# DataClassesDataContext类的具体用法?C# DataClassesDataContext怎么用?C# DataClassesDataContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DataClassesDataContext类属于命名空间,在下文中一共展示了DataClassesDataContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Button1_Click

    protected void Button1_Click(object sender, EventArgs e)
    {
        DataClassesDataContext da = new DataClassesDataContext();

        var result1 = from n in da.user
                     where n.user_name == TextBox3.Text
                     select n.major;
        var result2 = from m in da.project
                      where m.project_num == DropDownList1.Text
                      select m.major;
        foreach (var n in result1)
        {
            foreach (var m in result2)
            {
                if (n != m)
                {
                    ClientScriptManager client = this.ClientScript;
                    client.RegisterStartupScript(this.GetType(), "55", "<script>alert('专业不符!');history.back()</script>");
                    return;
                }
            }
        }
        proposal p = new proposal();
        p.proposal1 = TextBox1.Text;
        p.project_num = DropDownList1.Text;
        p.teacher_name = DropDownList2.Text;
        p.user_name = TextBox3.Text;
        p.proposal_num = TextBox2.Text;
        da.proposal.InsertOnSubmit(p);
        da.SubmitChanges();
        GridView1.DataBind();
    }
开发者ID:xwh,项目名称:hwh,代码行数:32,代码来源:Addproposal.aspx.cs

示例2: Index

        public ActionResult Index(string username, string password)
        {
            DataClassesDataContext db = new DataClassesDataContext();
            if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
            {
                return View();
            }

            if (db.Users.Where(u => u.nick == username).Count() < 1)
            {
                db.Users.InsertOnSubmit(new User { nick = username, password = password });
                db.SubmitChanges();
            }

            if (db.Users.Where(u => u.nick == username && u.password == password).Count() > 0)
            {
                Session["login"] = true;
                Session["nick"] = username;
                Session["userid"] = db.Users.Where(u => u.nick == username).First().id;
                Session["type"] = db.Users.Where(u => u.nick == username).First().type;

                return RedirectToAction("Index", "Chat");
            }
            else
            {
                ViewBag.ErrorMessage = "Nicket er ikke tilgjengelig!";
                return View();
            }
        }
开发者ID:khlieng,项目名称:ASPOblig,代码行数:29,代码来源:HomeController.cs

示例3: BuildEditorNavigation

    public string BuildEditorNavigation()
    {
        DataClassesDataContext db = new DataClassesDataContext();

        string category_id = "0";
        if (Request.QueryString["category_id"] != null)
        {
            category_id = Request.QueryString["category_id"].ToString();
        }

        string MenuItems = "";
        List<dbCategory> kategori_title = new List<dbCategory>();
        if (Convert.ToInt32(Session["role_access"]) >= 100)
        {
            kategori_title = db.dbCategories.OrderBy(i => i.Id).ToList();
        }
        else
        {
            kategori_title = db.dbCategoryEditors.Where(i => i.UserId == Convert.ToInt32(Session["user_id"])).Select(ce => ce.dbCategory).OrderBy(i => i.Id).ToList();
        }
        foreach (var item in kategori_title)
        {
            string active = (Request.RawUrl.Contains("News.aspx") && category_id == item.Id.ToString() ? " class='active'" : "");
            MenuItems += String.Format("<li{2}><a href='{0}'>{1}</a></li>", "News.aspx?category_id=" + item.Id, item.Title, active);
        }
        return MenuItems;
    }
开发者ID:JesperPetersenDk,项目名称:web-integrator-opgaver,代码行数:27,代码来源:MasterPage_Backend.master.cs

示例4: Getauthor

        public musicdata[] Getauthor(string author)
        {
            //if (!Hasmusic(author))
            //{
            //    var error = new CustomFaultMsg { Message = "Không có bài nào author là : " + author };
            //    throw new FaultException<CustomFaultMsg>(error, error.Message);
            //}
            using (var musicct = new DataClassesDataContext())
            {
                var song = from music in musicct.SONGs
                           where music.MUSICIAN.IndexOf(author) != -1
                           select new musicdata

                           {
                               Id = music.SONGID.ToString(),
                               aTitle = music.SONGNAME,
                               bAuthor = music.MUSICIAN,
                               Lang = music.LANGUAGE,
                               cSinger = music.SINGER.SINGERNAME,
                               eGenre = music.CATEGORY,
                               dPublish = music.PUBLISH.ToString(),
                               Karaoke = music.KARAOKE.ToString(),
                               Emotion = music.EMOTION.EMOTIONTYPE,
                               Instrument = music.INSTRUMENT,
                               Lyric = music.LYRICS
                           };
                return song.ToList().ToArray();
            }
        }
开发者ID:thainhan,项目名称:Nhom7,代码行数:29,代码来源:MiService.cs

示例5: LinkButtonCredit_Click

    protected void LinkButtonCredit_Click(object sender, EventArgs e)
    {
        PanelCredit.Visible = true;
        PanelAdd.Visible = false;
        PanelLog.Visible = false;
        LinkButtonCredit.Enabled = false;
        LinkButtonAdd.Enabled = true;
        LinkButtonLog.Enabled = true;

        DataClassesDataContext context = new DataClassesDataContext();
        int Userid = Convert.ToInt32(Session["UserId"]);
        var query2 = context.Credits.Where(c => c.UserId == Userid).FirstOrDefault();
        if (query2 != null)
        {
            LabelGiftCredit.Text = query2.GiftCredit.ToString();
            LabelSpendGift.Text = query2.SpentGift.ToString();
            LabelSpentCreadit.Text = query2.SpentCredit.ToString();
            LabelCredit.Text = query2.Credit1.ToString();
        }
        else if (query2 == null)
        {
            LabelGiftCredit.Text = " 0 ";
            LabelSpendGift.Text = " 0 ";
            LabelSpentCreadit.Text = " 0 ";
            LabelCredit.Text = " 0 ";
        }
    }
开发者ID:farhad85,项目名称:Salestan,代码行数:27,代码来源:Credit.aspx.cs

示例6: GetSlides

    public AjaxControlToolkit.Slide[] GetSlides(String contextKey)
    {
        List<AjaxControlToolkit.Slide> slides = new List<AjaxControlToolkit.Slide>();
        if (String.IsNullOrEmpty(contextKey))
            contextKey = "2";

        int artIndex = -1;
        if (int.TryParse(contextKey, out artIndex))
        {
            DataClassesDataContext dtx = new DataClassesDataContext();
            var pics = from p in dtx.Pictures
                       where p.ArticleId == artIndex
                       select new
                       {
                           Id = p.Id,
                           Title = p.Title
                       };

            foreach (var p in pics)
            {
                slides.Add(new AjaxControlToolkit.Slide("sqlimage.axd?name=pic&picId=" + p.Id, p.Title, ""));
            }
        }

        return slides.ToArray();
    }
开发者ID:MrCsabaToth,项目名称:ProFazekWebSite,代码行数:26,代码来源:SlideShowService.cs

示例7: initDutyTable

 private void initDutyTable()
 {
     DataClassesDataContext db = new DataClassesDataContext();
     FillTable ft = new FillTable(10, 7);
     ft.creatDataArray(db.Duty.ToList());
     ft.fillDataArrayToTable(DutyTable,NoValueDisplay.NoValueString);
 }
开发者ID:friends,项目名称:LibraryAssistant,代码行数:7,代码来源:Default.aspx.cs

示例8: getPostingByID

    public IQueryable<ndhCareer> getPostingByID(int _id)
    {
        DataClassesDataContext objDataClassesDC = new DataClassesDataContext();

        var postingID = objDataClassesDC.ndhCareers.Where(x => x.id == _id).Select(x => x);
        return postingID;
    }
开发者ID:CurtisHeaslip,项目名称:ndhproject,代码行数:7,代码来源:careersLinqClass.cs

示例9: getPosting

 public IQueryable<ndhCareer> getPosting()
 {
     DataClassesDataContext objDataClassesDC = new DataClassesDataContext();
     //var allPostings = from x in objDataClassesDC.ndhCareers select x;
     var allPostings = objDataClassesDC.ndhCareers.Select(x => x); //method syntax
     return allPostings;
 }
开发者ID:CurtisHeaslip,项目名称:ndhproject,代码行数:7,代码来源:careersLinqClass.cs

示例10: SubmitButton_Click

    protected void SubmitButton_Click(object sender, EventArgs e)
    {
        TextBox commentCtrl = (TextBox)CommentsLoginView.FindControl("CommentTextBox");
        if (commentCtrl != null && commentCtrl.Text.Length > 0)
        {
            using (DataClassesDataContext dtx = new DataClassesDataContext())
            {
                int aid = 0;
                MembershipUser mu = Membership.GetUser(HttpContext.Current.User.Identity.Name);
                if (int.TryParse(Context.Request["aid"], out aid))
                {
                    var comment = new Comment()
                    {
                        ArticleId = aid,
                        UserId = (Guid)mu.ProviderUserKey,
                        Body = commentCtrl.Text,
                        Created = System.DateTime.Now
                    };
                    dtx.Comments.InsertOnSubmit(comment);
                    dtx.SubmitChanges();

                    CommentService c = new CommentService();
                    CommentsDataList.DataSource = c.GetComments(aid);
                    CommentsDataList.DataBind();
                }
                commentCtrl.Text = "";
            }
        }
    }
开发者ID:MrCsabaToth,项目名称:ProFazekWebSite,代码行数:29,代码来源:ArticleCommentsControl.ascx.cs

示例11: button1_Click

    protected void button1_Click(object sender, EventArgs e)
    {
        if (textbox1.Text.Equals(String.Empty) || textbox2.Text.Equals(String.Empty))
        {
            Label1.Text = "评论内容与验证码不能为空";
            return;
        }
        try
        {
            if (!Request.Cookies["ValiCode"].Value.ToString().Equals(textbox2.Text))
            {
                Label1.Text = "验证码错误";
                return;
            }
            Table_DocumentComment comment = new Table_DocumentComment();
            comment.AccountName = Session["name"].ToString();
            comment.AccountType = Session["type"].ToString();
            comment.Comment = textbox1.Text;
            comment.Date = DateTime.Now;
            comment.DocumentId = (Int32)Session["document"];
            DataClassesDataContext data = new DataClassesDataContext();
            data.Table_DocumentComment.InsertOnSubmit(comment);
            data.SubmitChanges();
            comments.Add(comment);
            textbox1.Text = String.Empty;
            textbox2.Text = String.Empty;
            Label1.Text = String.Empty;

        }
        catch (Exception) { }
    }
开发者ID:JNU-Web-10-11,项目名称:JNU-Web,代码行数:31,代码来源:ReadDocument.aspx.cs

示例12: initDutyTable

 private void initDutyTable(string id)
 {
     DataClassesDataContext db = new DataClassesDataContext();
     FillTable ft = new FillTable(10, 7);
     ft.creatDataArray(db.Duty.Where(dutys=>dutys.assistantID==id).ToList());
     ft.fillDataArrayToTable(DutyTable,NoValueDisplay.Nothing);
 }
开发者ID:friends,项目名称:LibraryAssistant,代码行数:7,代码来源:Personal.aspx.cs

示例13: PrzydzielZadanieButton_Click

    protected void PrzydzielZadanieButton_Click(object sender, EventArgs e)
    {
        List<int> idGrupList = new List<int>();
        for (int i = 0; i < EnableGroupsListView.Items.Count; i++)
        {
            CheckBox chk = EnableGroupsListView.Items[i].FindControl("NazwaCheckBox") as CheckBox;
            if (chk != null && chk.Checked)
            {
                idGrupList.Add((int)EnableGroupsListView.DataKeys[i].Value);
            }
        }

        DataClassesDataContext db = new DataClassesDataContext();
        Zadania zadanie = db.Zadanias.FirstOrDefault(g => g.IdZadania == (int)((DataKey)Session["IdZadania"]).Value);
        foreach (int id in idGrupList)
        {
            ZadaniawGrupach zadaniawGrupach = new ZadaniawGrupach
                                                  {
                                                      Zadania = zadanie,
                                                      IdGrupy = id,
                                                      DataDodania = DateTime.Now
                                                  };
            db.ZadaniawGrupaches.InsertOnSubmit(zadaniawGrupach);
        }
        db.SubmitChanges();
        WczytajListeGrup(db);
        SuccesLabel.Text = "Dodano zadanie do grup/y";
        SuccesLabel.ForeColor = System.Drawing.Color.Green;
    }
开发者ID:Krzem0,项目名称:KlojSpon,代码行数:29,代码来源:Zadanie.aspx.cs

示例14: GetAll

 public List<PersonData> GetAll()
 {
     var ctx = WebOperationContext.Current;
     try
     {
         using (var personCtx = new DataClassesDataContext())
         {
             // Set up the query
             var persons = from p in personCtx.Persons
                           orderby p.FirstName
                           select new PersonData
                           {
                               PersonId = p.PersonId,
                               FirstName = p.FirstName,
                               LastName = p.LastName,
                               EmailAddress = p.EmailAddress,
                               Department = p.Department
                           };
             ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK;
             return persons.ToList();
         }
     }
     catch
     {
         ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.BadRequest;
         return null;
     }
 }
开发者ID:vantrung87hvt,项目名称:liemqv-android,代码行数:28,代码来源:RESTHRService.cs

示例15: GetPerson

    public PersonData GetPerson(string personId)
    {
        var ctx = WebOperationContext.Current;
        try
        {
            using (var personCtx = new DataClassesDataContext())
            {
                // Set up the query
                var person = personCtx.Persons.SingleOrDefault(p => p.PersonId == Convert.ToInt32(personId));

                if (person == null)
                {
                    ctx.OutgoingResponse.SetStatusAsNotFound();
                    return null;
                }
                var personData = new PersonData
                                          {
                                              PersonId = person.PersonId,
                                              FirstName = person.FirstName,
                                              LastName = person.LastName,
                                              EmailAddress = person.EmailAddress,
                                              Department = person.Department
                                          };

                ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK;
                return personData;
            }
        }
        catch
        {
            ctx.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.BadRequest;
            return null;
        }
    }
开发者ID:vantrung87hvt,项目名称:liemqv-android,代码行数:34,代码来源:RESTHRService.cs


注:本文中的DataClassesDataContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。