Exemplo n.º 1
0
    protected void butSubmit_Click(object sender, EventArgs e)
    {
        int playerId = int.Parse(Request.QueryString["player"]);

        MlbDataContext mlbData = new MlbDataContext();

        CONTRACT con = (from c in mlbData.CONTRACTs
                        where c.Player == playerId
                        select c).SingleOrDefault();

        if (con == null)
        {
            con = new CONTRACT();
            con.Player = playerId;
            mlbData.CONTRACTs.InsertOnSubmit(con);
        }
        con.YearSigned = int.Parse(drpYearSigned.Text);
        mlbData.SubmitChanges();

        foreach (string key in Request.Form.Keys)
        {
            int index = key.IndexOf("Salary");
            if (index >= 0)
            {
                int year = int.Parse(key.Substring(index + 6));
                var conYear = (from cy in mlbData.CONTRACT_YEARs
                               where cy.Contract == con.CONTRACT_ID && cy.Year == year
                               select cy).SingleOrDefault();

                if (conYear == null)
                {
                    conYear = new CONTRACT_YEAR();
                    conYear.Contract = con.CONTRACT_ID;
                    conYear.Year = year;
                    mlbData.CONTRACT_YEARs.InsertOnSubmit(conYear);
                }
                conYear.Salary = decimal.Parse(Request.Form[key]);
            }
        }
        mlbData.SubmitChanges();
    }
Exemplo n.º 2
0
 partial void DeleteCONTRACT_YEAR(CONTRACT_YEAR instance);
Exemplo n.º 3
0
 partial void InsertCONTRACT_YEAR(CONTRACT_YEAR instance);
Exemplo n.º 4
0
 partial void UpdateCONTRACT_YEAR(CONTRACT_YEAR instance);
Exemplo n.º 5
0
		private void detach_CONTRACT_YEARs(CONTRACT_YEAR entity)
		{
			this.SendPropertyChanging();
			entity.CONTRACT1 = null;
		}