protected void uiLinkButtonAddItem_Click(object sender, EventArgs e) { /* get items from stock */ IStock.BLL.Items item = new IStock.BLL.Items(); item.LoadByPrimaryKey(Convert.ToInt32(uiHiddenFieldCurrentItem.Value)); if (!item.IsColumnNull("Quantity")) { if (item.Quantity == 0 || Convert.ToInt32(uiTextBoxQty.Text) > item.Quantity) { ErrorDiv.Visible = true; uiLabelError.Text = GetLocalResourceObject("ItemQtyError").ToString(); return; } item.Quantity -= Convert.ToInt32(uiTextBoxQty.Text); } else { ErrorDiv.Visible = true; uiLabelError.Text = GetLocalResourceObject("ItemQtyError").ToString(); return; } item.Save(); /* get items from stock */ IStock.BLL.DeliveryOrderDetails detail = new IStock.BLL.DeliveryOrderDetails(); detail.AddNew(); detail.DeliveryOrderID = CurrentDeliveryOrder.DeliveryOrderID; detail.ItemID = Convert.ToInt32(uiHiddenFieldCurrentItem.Value); //detail.ItemID = Convert.ToInt32(uiDropDownListItems.SelectedValue); detail.Quantity = Convert.ToInt32(uiTextBoxQty.Text); detail.ItemPrice = decimal.Parse(uiTextBoxPrice.Text); detail.Save(); decimal price = 0; if (!CurrentDeliveryOrder.IsColumnNull("Discount") && CurrentDeliveryOrder.Discount != 0) { price = detail.ItemPrice * detail.Quantity * (CurrentDeliveryOrder.Discount / 100); } else { price = detail.ItemPrice * detail.Quantity; } IStock.BLL.Clients client = new IStock.BLL.Clients(); client.LoadByPrimaryKey(CurrentDeliveryOrder.ClientID); if (!client.IsColumnNull("StartCredit")) client.StartCredit += price; else client.StartCredit = price; client.Save(); ErrorDiv.Visible = false; uiTextBoxItems.Text = ""; uiTextBoxPrice.Text = ""; uiTextBoxQty.Text = ""; BindItems(); }