public WorkOrder GetWorkOrder(int workOrderId)
        {
            WorkOrder workOrder = new WorkOrder();

            using (IDataReader dr = new WorkOrderDataAdapter().GetWorkOrderById(workOrderId))
            {
                if (dr.Read())
                {
                    workOrder = PopulateReader(dr);
                }
                dr.Close();
            }
            return workOrder;
        }
 public WorkOrderCollection GetTop5Materials()
 {
     WorkOrderCollection workOrderCollection = new WorkOrderCollection();
     using (IDataReader dr = new WorkOrderDataAdapter().GetTop5Materials())
     {
         while (dr.Read())
         {
             WorkOrder workOrder = new WorkOrder();
             workOrder.MaterialId = dr["MaterialId"].ToString();
             workOrderCollection.Add(workOrder);
         }
         dr.Close();
     }
     return workOrderCollection;
 }
 public WorkOrderCollection GetTop5Customers()
 {
     WorkOrderCollection workOrderCollection = new WorkOrderCollection();
     using (IDataReader dr = new WorkOrderDataAdapter().GetTop5Customers())
     {
         while (dr.Read())
         {
             WorkOrder workOrder = new WorkOrder();
             workOrder.CustomerId = Convert.ToInt32(dr["CustomerId"]);
             workOrderCollection.Add(workOrder);
         }
         dr.Close();
     }
     return workOrderCollection;
 }
Пример #4
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        WorkOrderModule workOrderModule = new WorkOrderModule();
        InventorySystem.Business.WorkOrder workOrder = new InventorySystem.Business.WorkOrder();
        if (ViewState["id"] == null)
        {
            workOrder.Id = workOrderModule.GetMaxId() + 1;
        }
        else
        {
            workOrder.Id = Convert.ToInt32(ViewState["id"]);
        }

        workOrder.CustomerId = Convert.ToInt32(ddlCustomers.SelectedValue);
        workOrder.Description = txtDescription.Text;
        workOrder.MaterialId = ddlMaterial.SelectedValue;

        if (txtQuantity.Text != "")
            workOrder.Quantity = Convert.ToInt32(txtQuantity.Text);
        if (txtPatternCost.Text != "")
        workOrder.PatternCost = Convert.ToDecimal(txtPatternCost.Text);
        if (txtMachiningCost.Text != "")
        workOrder.MachiningCost = Convert.ToDecimal(txtMachiningCost.Text);
        if (txtCastingWeight.Text != "")
        workOrder.CastingWeight = Convert.ToInt32(txtCastingWeight.Text);
        workOrder.Others = txtOthers.Text;
        if (txtModificationCost.Text != "")
        workOrder.ModificationCost = Convert.ToDecimal(txtModificationCost.Text);
        if (txtTotalCost.Text != "")
        workOrder.TotalCost = Convert.ToDecimal(txtTotalCost.Text);
        if (txtDescription.Text != "")
        workOrder.DeliveryDateTime = Convert.ToDateTime(txtDeliveryDateTime.Text);
        workOrder.Remarks = txtRemarks.Text;
        workOrderModule.Save(workOrder);
        gvWorkOrder.DataBind();
        Helper.EnableControls(false, Helper.GetControlsInPlaceHolder("InfoPlaceHolder", Master));
        btnSave.Enabled = false;
    }
Пример #5
0
 public void Save(WorkOrder workOrder)
 {
     workOrder.Save();
 }
        private WorkOrder PopulateReader(IDataReader dr)
        {
            WorkOrder workOrder = new WorkOrder();
            if (dr["Id"] != DBNull.Value)
                workOrder.Id = Convert.ToInt32(dr["Id"]);
            workOrder.CustomerId = Convert.ToInt32(dr["CustomerId"]);
            workOrder.Description = dr["Description"].ToString();
            workOrder.MaterialId = dr["MaterialId"].ToString();
            workOrder.Quantity = Convert.ToInt32(dr["Quantity"]);
            workOrder.CastingWeight = Convert.ToInt32(dr["CastingWeight"]);
            workOrder.PatternCost = Convert.ToDecimal(dr["PatternCost"]);
            workOrder.MachiningCost = Convert.ToDecimal(dr["MachiningCost"]);
            workOrder.ModificationCost = Convert.ToDecimal(dr["ModificationCost"]);
            workOrder.TotalCost = Convert.ToDecimal(dr["TotalCost"]);
            workOrder.Others = dr["Others"].ToString();
            workOrder.DeliveryDateTime = Convert.ToDateTime(dr["DeliveryDateTime"]);
            workOrder.Remarks = dr["Remarks"].ToString();

            return workOrder;
        }
 public bool Update(WorkOrder workOrder)
 {
     return new WorkOrderDataAdapter().UpdateWorkOrder(workOrder.Id,
                             workOrder.CustomerId, workOrder.Description,
                             workOrder.MaterialId, workOrder.Quantity,
                             workOrder.CastingWeight, workOrder.PatternCost,
                             workOrder.MachiningCost, workOrder.ModificationCost,
                             workOrder.TotalCost, workOrder.Others, workOrder.DeliveryDateTime,
                             workOrder.Remarks);
 }