コード例 #1
0
        protected void ButtonAddMaterial_Click(object sender, EventArgs e)
        {
            OrderLine NewLine = new OrderLine();
            Material  MatItem;
            RelationPriceAgreement   PAItem;
            RelationContractMaterial ContractItem;

            DetermineCurrentSelectedMaterial(out MatItem, out PAItem, out ContractItem);

            NewLine.Order = (DataItem as Order);
            try
            {
                NewLine.PricePerUnit             = Convert.ToDouble(TextBoxPrice.Text);
                NewLine.Amount                   = Convert.ToDouble(TextBoxAmount.Text);
                NewLine.Material                 = MatItem;
                NewLine.Description              = MatItem.Description;
                NewLine.RelationPriceAgreement   = PAItem;
                NewLine.RelationContractMaterial = ContractItem;
                ControlObjectContext.AddToOrderLineSet(NewLine);

                (DataItem as Order).RecalcTotals();
            }
            catch { }

            try
            {
                ControlObjectContext.SaveChanges(SaveOptions.DetectChangesBeforeSave);
            }
            catch (Exception ex)
            {
                Common.InformUserOnTransactionFail(ex, Page);
            }

            DataBind();
        }