Beispiel #1
0
        private void button9_Click(object sender, EventArgs e)      //insert od
        {
            short oid = Convert.ToInt16(textodid.Text);
            IQueryable <ORDER> odt = from od in context.ORDERs where od.ORDERID == oid select od;

            if (odt.Count() <= 0)
            {
                MessageBox.Show("Invalid Order ID!");
            }
            else
            {
                odt.First().VALOARE += Convert.ToDecimal(textodvaloare.Text);   //val stuff
                try
                {
                    ORDERDETAIL selod = new ORDERDETAIL();
                    selod.ORDERID = oid;
                    selod.PRODUS  = textodprodus.Text;
                    selod.VALOARE = Convert.ToDecimal(textodvaloare.Text);
                    selod.SERIAL  = Convert.ToInt16(textodserial.Text);
                    context.AddToORDERDETAILS(selod);
                    int rowsAffected = context.SaveChanges(false);
                    textCh.Text = rowsAffected.ToString() + " changes made to the orderdetails (insert)";
                }
                catch (UpdateException ex)
                {
                    MessageBox.Show("Invalid Key!");
                }
            }
        }
Beispiel #2
0
        private void button8_Click(object sender, EventArgs e)      //update od
        {
            try
            {
                decimal     oval  = Convert.ToDecimal(textodvaloare.Text);
                string      oprod = textodprodus.Text;
                ORDERDETAIL selod = (ORDERDETAIL)comboODetails.SelectedItem;
                if (oval != selod.VALOARE)
                {
                    selod.ORDER.VALOARE = selod.ORDER.VALOARE - selod.VALOARE + oval;
                }
                selod.PRODUS = oprod;
                if (selod.ORDERID != Convert.ToInt16(textodid.Text) || selod.SERIAL != Convert.ToInt16(textodserial.Text))
                {
                    throw new InvalidOperationException();
                }

                int rowsAffected = context.SaveChanges(false);
                textCh.Text = rowsAffected.ToString() + " changes made to the orderdetails (update)";
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show("Invalid orderId/serial !");
            }
        }
Beispiel #3
0
        private void comboODetails_SelectedIndexChanged(object sender, EventArgs e)
        {
            ORDERDETAIL selod = (ORDERDETAIL)comboODetails.SelectedItem;

            textodid.Text      = selod.ORDERID.ToString();
            textodprodus.Text  = selod.PRODUS;
            textodvaloare.Text = selod.VALOARE.ToString();
            textodserial.Text  = selod.SERIAL.ToString();
        }
Beispiel #4
0
        /// <summary>
        /// Create a new ORDERDETAIL object.
        /// </summary>
        /// <param name="oRDERID">Initial value of the ORDERID property.</param>
        /// <param name="pRODUS">Initial value of the PRODUS property.</param>
        /// <param name="vALOARE">Initial value of the VALOARE property.</param>
        /// <param name="sERIAL">Initial value of the SERIAL property.</param>
        public static ORDERDETAIL CreateORDERDETAIL(global::System.Int16 oRDERID, global::System.String pRODUS, global::System.Decimal vALOARE, global::System.Int16 sERIAL)
        {
            ORDERDETAIL oRDERDETAIL = new ORDERDETAIL();

            oRDERDETAIL.ORDERID = oRDERID;
            oRDERDETAIL.PRODUS  = pRODUS;
            oRDERDETAIL.VALOARE = vALOARE;
            oRDERDETAIL.SERIAL  = sERIAL;
            return(oRDERDETAIL);
        }
Beispiel #5
0
        private void button14_Click(object sender, EventArgs e)     //delete od
        {
            ORDERDETAIL selod = (ORDERDETAIL)comboODetails.SelectedItem;

            selod.ORDER.VALOARE -= selod.VALOARE;
            context.DeleteObject(selod);
            int rowsAffected = context.SaveChanges(false);

            textCh.Text = rowsAffected.ToString() + " changes made to the orderdetails (delete)";
        }
Beispiel #6
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ORDERDETAILS EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToORDERDETAILS(ORDERDETAIL oRDERDETAIL)
 {
     base.AddObject("ORDERDETAILS", oRDERDETAIL);
 }
Beispiel #7
0
 //insert od
 private void button9_Click(object sender, EventArgs e)
 {
     short oid = Convert.ToInt16(textodid.Text);
     IQueryable<ORDER> odt = from od in context.ORDERs where od.ORDERID == oid select od;
     if (odt.Count() <= 0)
         MessageBox.Show("Invalid Order ID!");
     else
     {
         odt.First().VALOARE += Convert.ToDecimal(textodvaloare.Text);   //val stuff
         try
         {
             ORDERDETAIL selod = new ORDERDETAIL();
             selod.ORDERID = oid;
             selod.PRODUS = textodprodus.Text;
             selod.VALOARE = Convert.ToDecimal(textodvaloare.Text);
             selod.SERIAL = Convert.ToInt16(textodserial.Text);
             context.AddToORDERDETAILS(selod);
             int rowsAffected = context.SaveChanges(false);
             textCh.Text=rowsAffected.ToString() + " changes made to the orderdetails (insert)";
         }
         catch (UpdateException ex)
         {
             MessageBox.Show("Invalid Key!");
         }
     }
 }
 /// <summary>
 /// Create a new ORDERDETAIL object.
 /// </summary>
 /// <param name="oRDERID">Initial value of the ORDERID property.</param>
 /// <param name="pRODUS">Initial value of the PRODUS property.</param>
 /// <param name="vALOARE">Initial value of the VALOARE property.</param>
 /// <param name="sERIAL">Initial value of the SERIAL property.</param>
 public static ORDERDETAIL CreateORDERDETAIL(global::System.Int16 oRDERID, global::System.String pRODUS, global::System.Decimal vALOARE, global::System.Int16 sERIAL)
 {
     ORDERDETAIL oRDERDETAIL = new ORDERDETAIL();
     oRDERDETAIL.ORDERID = oRDERID;
     oRDERDETAIL.PRODUS = pRODUS;
     oRDERDETAIL.VALOARE = vALOARE;
     oRDERDETAIL.SERIAL = sERIAL;
     return oRDERDETAIL;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the ORDERDETAILS EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToORDERDETAILS(ORDERDETAIL oRDERDETAIL)
 {
     base.AddObject("ORDERDETAILS", oRDERDETAIL);
 }