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;
    }
 protected void btnDelete_Click(object sender, EventArgs e)
 {
     WorkOrderModule workOrderModule = new WorkOrderModule();
     workOrderModule.Delete(Convert.ToInt32(ViewState["id"]));
     gvWorkOrder.DataBind();
 }
 protected void btnSearch_Click(object sender, EventArgs e)
 {
     WorkOrderCollection workOrders = new WorkOrderModule().GetWorkOrdersByCustomerName(txtSearch.Text);
     gvWorkOrder.DataSourceID = null;
     gvWorkOrder.DataSource = workOrders;
     gvWorkOrder.DataBind();
 }