protected void CV_ServerValidate(object source, ServerValidateEventArgs args) { CustomValidator cv = (CustomValidator)source; switch (cv.ID) { case "cvCode": if (TheVehicleMgr.LoadVehicle(args.Value) != null) { ShowWarningMessage("Transportation.Vehicle.Code.Exists", args.Value); args.IsValid = false; } break; case "cvCarrier": if (TheCarrierMgr.LoadCarrier(args.Value) == null) { ShowWarningMessage("Transportation.Carrier.Code.NotExist", args.Value); args.IsValid = false; } break; default: break; } }
protected void lbtnDelete_Click(object sender, EventArgs e) { string code = ((LinkButton)sender).CommandArgument; try { TheVehicleMgr.DeleteVehicle(code); ShowSuccessMessage("Transportation.Vehicle.DeleteVehicle.Successfully", code); UpdateView(); } catch { ShowErrorMessage("Transportation.Vehicle.DeleteVehicle.Fail", code); } }
protected void tbVehicle_TextChanged(object sender, EventArgs e) { Controls_TextBox tbVehicle = (Controls_TextBox)(this.FV_Order.FindControl("tbVehicle")); string vehicleCode = tbVehicle.Text.Trim(); if (vehicleCode != String.Empty) { Vehicle vehicle = TheVehicleMgr.LoadVehicle(vehicleCode); if (vehicle != null) { Controls_TextBox tbCarrier = (Controls_TextBox)(this.FV_Order.FindControl("tbCarrier")); if (vehicle.Carrier != null) { tbCarrier.Text = vehicle.Carrier.Code; Controls_TextBox tbCarrierBillAddress = (Controls_TextBox)(this.FV_Order.FindControl("tbCarrierBillAddress")); BillAddress carrierBillAddress = TheBillAddressMgr.GetDefaultBillAddress(vehicle.Carrier.Code); if (carrierBillAddress != null) { tbCarrierBillAddress.Text = carrierBillAddress.Code; } } if (vehicle.Carrier != null) { tbCarrier.Text = vehicle.Carrier.Code; } DropDownList ddlType = (DropDownList)(this.FV_Order.FindControl("ddlType")); if (vehicle.Type != null) { ddlType.SelectedValue = vehicle.Type; } TextBox tbDriver = (TextBox)(this.FV_Order.FindControl("tbDriver")); if (vehicle.Driver != null) { tbDriver.Text = vehicle.Driver; } } } }