protected virtual void dvOrderHeader_OnDataBound(Object sender, EventArgs e) { if (dvOrderHeader.CurrentMode == DetailsViewMode.ReadOnly) { if (Session[CONST_ORDERHEADERVALUES] != null) { // this is a update of the header items TrackerDotNet.control.OrderHeaderData _OldOrderHeader = (OrderHeaderData)Session[CONST_ORDERHEADERVALUES]; string _NewDateStr = GetOrderHeaderRequiredByDateStr(); if (!_NewDateStr.Equals(string.Empty)) { DateTime _NewRequireDate = Convert.ToDateTime(GetOrderHeaderRequiredByDateStr()).Date; if (_OldOrderHeader.OrderDate.Date != _NewRequireDate.Date) { UsedItemGroupTbl _UsedItems = new UsedItemGroupTbl(); DropDownList _gvItemDLL = null; // chjeck in each item of the grid if the item was a group item foreach (GridViewRow _gvr in gvOrderLines.Rows) { _gvItemDLL = (DropDownList)_gvr.FindControl("ddlItemDesc"); _UsedItems.UpdateIfGroupItem(_OldOrderHeader.CustomerID, Convert.ToInt32(_gvItemDLL.SelectedValue), _OldOrderHeader.RequiredByDate, _NewRequireDate); } } } } Label lblPurchaseOrder = (Label)dvOrderHeader.FindControl("lblPurchaseOrder"); if ((lblPurchaseOrder != null) && (lblPurchaseOrder.Text.Equals(TrackerTools.CONST_POREQUIRED))) { lblPurchaseOrder.BackColor = System.Drawing.Color.Red; lblPurchaseOrder.ForeColor = System.Drawing.Color.White; } } CheckBox thisCheckBox = (CheckBox)dvOrderHeader.FindControl("cbxDone"); if (thisCheckBox != null) { btnOrderDelivered.Enabled = btnOrderCancelled.Enabled = !thisCheckBox.Checked; } updtButtonPanel.Update(); }
/// <summary> /// Something in the header data has changed so do a generic update /// </summary> protected void DoHeaderUpdate() { List <string> _OrderIds = (List <string>)Session[CONST_ORDERLINEIDS]; List <int> _OrderItemIds = (List <int>)Session[CONST_ORDERLINEITEMIDS]; if (_OrderIds.Count > 0) { OrderDataControl _myDB = new OrderDataControl(); OrderHeaderData _OrderHeader = new OrderHeaderData(); _OrderHeader.CustomerID = Convert.ToInt64(ddlContacts.SelectedValue); _OrderHeader.OrderDate = Convert.ToDateTime(tbxOrderDate.Text); _OrderHeader.RoastDate = Convert.ToDateTime(tbxRoastDate.Text); _OrderHeader.ToBeDeliveredBy = Convert.ToInt64(ddlToBeDeliveredBy.SelectedValue); _OrderHeader.RequiredByDate = Convert.ToDateTime(tbxRequiredByDate.Text); _OrderHeader.Confirmed = cbxConfirmed.Checked; _OrderHeader.Done = cbxDone.Checked; _OrderHeader.InvoiceDone = cbxInvoiceDone.Checked; _OrderHeader.PurchaseOrder = tbxPurchaseOrder.Text; _OrderHeader.Notes = tbxNotes.Text; _myDB.UpdateOrderHeader(_OrderHeader, _OrderIds); // if date has changed since item added then see if one of the items was a group item and change that date too DateTime _OldRequiredByDate = _OrderHeader.RequiredByDate; if (Session[OrderHeaderData.CONST_BOUNDOLDDELIVERYDATE] != null) { _OldRequiredByDate = ((DateTime)Session[OrderHeaderData.CONST_BOUNDOLDDELIVERYDATE]).Date; } if (!_OldRequiredByDate.Equals(_OrderHeader.RequiredByDate)) { UsedItemGroupTbl _UsedItems = new UsedItemGroupTbl(); foreach (int _OrderItemId in _OrderItemIds) { _UsedItems.UpdateIfGroupItem(_OrderHeader.CustomerID, _OrderItemId, _OldRequiredByDate, _OrderHeader.RequiredByDate); } Session[OrderHeaderData.CONST_BOUNDOLDDELIVERYDATE] = _OrderHeader.RequiredByDate.Date; } } BindRowQueryParameters(); }