/// <summary> /// Getting the custom fields data from EquipData table /// </summary> /// <param name="bIsComponent">The boolean argument using for defining owner of data: the Equipment or the its component.</param> /// <param name="iTypeId">The integer argument for defining type of data</param> /// <param name="sContext_User_Identity">The Org string</param> /// <returns>Return the array containing data of custom fields in the clsCustomFieldsDef classes</returns> public static ArrayList GetCustomFields(bool bIsComponent, int iTypeId, string sContext_User_Identity) { ArrayList arrCFD = null; clsCustomFieldsDef cfd = null; clsCustFields custfield = null; DataTable dtFields = null; try { custfield = new clsCustFields(); arrCFD = new ArrayList(); custfield.iOrgId = GetUserOrgId(sContext_User_Identity, false); custfield.bitIsComponent = (SqlBoolean)bIsComponent; custfield.iComponentTypeID = (SqlInt32)iTypeId; dtFields = custfield.GetCustFields(); if (dtFields.Rows.Count == 0) { return(null); } for (int i = 0; i < dtFields.Rows.Count; i++) { cfd = new clsCustomFieldsDef(); cfd.Id = Convert.ToInt32(dtFields.Rows[i]["Id"]); cfd.NumberColumn = Convert.ToInt32(dtFields.Rows[i]["NumberColumn"]); cfd.Name = Convert.ToString(dtFields.Rows[i]["vchName"]); cfd.NameText = Convert.ToString(dtFields.Rows[i]["vchNameText"]); cfd.NameLookupTable = Convert.ToString(dtFields.Rows[i]["vchNameLookupTable"]); cfd.NameFieldLookup = Convert.ToString(dtFields.Rows[i]["vchNameFieldLookup"]); cfd.Required = Convert.ToBoolean(dtFields.Rows[i]["btRequired"]); cfd.FieldTypeId = (DBFieldType)Convert.ToInt32(dtFields.Rows[i]["intFieldTypeId"]); cfd.Default = Convert.ToString(dtFields.Rows[i]["vchDefault"]); cfd.Help = Convert.ToString(dtFields.Rows[i]["vchHelp"]); arrCFD.Add(cfd); cfd = null; } return(arrCFD); } catch (Exception ex) { throw new Exception(ex.Message); } finally { if (custfield != null) { custfield.Dispose(); } } }
/// <summary> /// Procedure is closing the custom fields of the work order /// </summary> private void ShowCustomFields() { int j; string sTypeName; try { // getting the custom fields of Work Order arrCFD = _functions.GetCustomFields(CFDataType.WorkOrder, 0, HttpContext.Current.User.Identity.Name); if(arrCFD != null) { // initializing the data table for custom fields dtCustomFields = new DataTable(); dtCustomFields.Columns.Add("TypeName"); dtCustomFields.Columns.Add("ValueName"); dtCustomFields.Columns.Add("Value_String"); dtCustomFields.Columns.Add("Value_Boolean"); dtCustomFields.Columns.Add("Value_Int"); dtCustomFields.Columns.Add("Value_DateTime"); dtCustomFields.Columns.Add("TB_Visible"); dtCustomFields.Columns.Add("DDL_Visible"); dtCustomFields.Columns.Add("CB_Visible"); dtCustomFields.Columns.Add("MM_Visible"); dtCustomFields.Columns.Add("DT_Visible"); dtCustomFields.Columns.Add("Help"); dtCustomFields.Columns.Add("RFV_Visible"); dtCustomFields.Columns.Add("Val_Visible"); dtCustomFields.Columns.Add("ErrorMessage"); dtCustomFields.Columns.Add("Exp"); DataColumn dcEnabled = new DataColumn("Enabled"); if(order.iStatusId.Value == (int)WorkOrderStatus.Open || order.iStatusId.Value == (int)WorkOrderStatus.ReOpened) dcEnabled.DefaultValue = "True"; else dcEnabled.DefaultValue = "False"; dtCustomFields.Columns.Add(dcEnabled); dtCustomFieldsFromDB = order.WorkOrderDetail_CustomFields(null); // filling custom fields in the dtCustomFields table for(j = 0; j < arrCFD.Count; j++) { cfd = (clsCustomFieldsDef)arrCFD[j]; sTypeName = _functions.GetFieldTypeText(cfd.FieldTypeId) + cfd.NumberColumn.ToString(); switch(cfd.FieldTypeId) { case DBFieldType._nvarchar: if(OrderId == 0) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, cfd.Required.ToString(), "False", "", ""}); else if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, cfd.Required.ToString(), "False", "", ""}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, dtCustomFieldsFromDB.Rows[0][sTypeName], "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, cfd.Required.ToString(), "False", "", ""}); break; case DBFieldType._int: if(OrderId == 0) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, cfd.Required.ToString(), "True", cfd.NameText + " must be numeric", "^\\d{0,10}?$"}); else if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, cfd.Required.ToString(), "True", cfd.NameText + " must be numeric", "^\\d{0,10}?$"}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, dtCustomFieldsFromDB.Rows[0][sTypeName], "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, cfd.Required.ToString(), "True", cfd.NameText + " must be numeric", "^\\d{0,10}?$"}); break; case DBFieldType._float: if(OrderId == 0) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, cfd.Required.ToString(), "True", cfd.NameText + " must be decimal numeric", "^\\d{0,8}(?:\\.\\d{0,8})?$"}); else if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, cfd.Required.ToString(), "True", cfd.NameText + " must be decimal numeric", "^\\d{0,8}(?:\\.\\d{0,8})?$"}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, dtCustomFieldsFromDB.Rows[0][sTypeName], "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, cfd.Required.ToString(), "True", cfd.NameText + " must be decimal numeric", "^\\d{0,8}(?:\\.\\d{0,8})?$"}); break; case DBFieldType._datetime: if(OrderId == 0) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "1970-01-01", "False", "False", "False", "False", "True", cfd.Help, "False", "False", "", ""}); else if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "1970-01-01", "False", "False", "False", "False", "True", cfd.Help, "False", "False", "", ""}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, dtCustomFieldsFromDB.Rows[0][sTypeName], "False", "False", "False", "False", "True", cfd.Help, "False", "False", "", ""}); break; case DBFieldType._bit: if(OrderId == 0) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "False", "False", "True", "False", "False", cfd.Help, "False", "False", "", ""}); else { if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "False", "False", "True", "False", "False", cfd.Help, "False", "False", "", ""}); else { if(((bool)dtCustomFieldsFromDB.Rows[0][sTypeName]) == true) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "True", 0, "2000-01-01", "False", "False", "True", "False", "False", cfd.Help, "False", "False", "", ""}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "False", "False", "True", "False", "False", cfd.Help, "False", "False", "", ""}); } } break; case DBFieldType._ntext: if(OrderId == 0) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "2000-01-01", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, cfd.Required.ToString(), "False", "", ""}); else { if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "2000-01-01", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, cfd.Required.ToString(), "False", "", ""}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, (string)dtCustomFieldsFromDB.Rows[0][sTypeName], "2000-01-01", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, cfd.Required.ToString(), "False", "", ""}); } break; case DBFieldType._sql_variant: if(OrderId == 0) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "2000-01-01", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, cfd.Required.ToString(), "False", "", ""}); else { if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "2000-01-01", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, cfd.Required.ToString(), "False", "", ""}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, (string)dtCustomFieldsFromDB.Rows[0][sTypeName], "2000-01-01", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, cfd.Required.ToString(), "False", "", ""}); } break; case DBFieldType._lookup: if(OrderId == 0) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, 0, "False", 0, "2000-01-01", "False", "True", "False", "False", "False", cfd.Help, "False", "False", "", ""}); else if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, 0, "False", 0, "2000-01-01", "False", "True", "False", "False", "False", cfd.Help, "False", "False", "", ""}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, dtCustomFieldsFromDB.Rows[0][sTypeName], "False", 0, "2000-01-01", "False", "True", "False", "False", "False", cfd.Help, "False", "False", "", ""}); break; default: break; } cfd = null; } // binding main datalist ViewState["CustomFields"] = dtCustomFields; repCustomFields.DataSource = new DataView(dtCustomFields); repCustomFields.DataBind(); } else ViewState["CustomFields"] = null; } catch(Exception ex) { throw new Exception(ex.Message, ex); } }
private void Page_Load(object sender, System.EventArgs e) { int j; string sTypeName; object oItem; try { if(Request.QueryString["id"] == null) { Session["lastpage"] = "view.aspx?id=" + Session["EquipId"].ToString(); Session["error"] = _functions.ErrorMessage(104); Response.Redirect("error.aspx", false); return; } try { ComponentId = Convert.ToInt32(Request.QueryString["id"]); } catch(FormatException fex) { Session["lastpage"] = "view.aspx?id=" + Session["EquipId"].ToString(); Session["error"] = _functions.ErrorMessage(105); Response.Redirect("error.aspx", false); return; } string [,] arrBrdCrumbs = new string [3,2]; arrBrdCrumbs[0,0]="main.aspx"; arrBrdCrumbs[0,1]="Home"; arrBrdCrumbs[1,0]="list.aspx"; arrBrdCrumbs[1,1]="Equipment List"; if(Session["EquipId"] != null) arrBrdCrumbs[2,0]= "view.aspx?id=" + Session["EquipId"].ToString(); else arrBrdCrumbs[2,0]= ParentPageURL; arrBrdCrumbs[2,1]="Equipment Detail"; PageTitle = "Equipment-Edit Component"; Header.BrdCrumbs=ParseBreadCrumbs(arrBrdCrumbs, PageTitle); Header.PageTitle=PageTitle; SaveCancelControl.ParentPageURL = ParentPageURL; if(!IsPostBack) { comp = new clsComponents(); dtCustomFields = new DataTable(); dtCustomFields.Columns.Add("TypeName"); dtCustomFields.Columns.Add("ValueName"); dtCustomFields.Columns.Add("Value_String"); dtCustomFields.Columns.Add("Value_Boolean"); dtCustomFields.Columns.Add("Value_Int"); dtCustomFields.Columns.Add("Value_DateTime"); dtCustomFields.Columns.Add("TB_Visible"); dtCustomFields.Columns.Add("DDL_Visible"); dtCustomFields.Columns.Add("CB_Visible"); dtCustomFields.Columns.Add("MM_Visible"); dtCustomFields.Columns.Add("DT_Visible"); dtCustomFields.Columns.Add("Help"); dtCustomFields.Columns.Add("Val_Visible"); dtCustomFields.Columns.Add("ErrorMessage"); dtCustomFields.Columns.Add("Exp"); if(ComponentId == 0) { // adding a component lblLastUpdate.Text = ""; ddlStatus.SelectedValue = "1"; ViewState["ComponentTypeId"] = Convert.ToInt32(Request.QueryString["typeid"]); btnRemove.Visible = false; } else { // editing a component comp.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); comp.iId = ComponentId; comp.cAction="S"; btnRemove.Visible = true; dtCustomFieldsFromDB = comp.ComponentDetail_CustomFields(null); lblLastUpdate.Text = dtCustomFieldsFromDB.Rows[0]["UserName"].ToString() + " " + Convert.ToDateTime(dtCustomFieldsFromDB.Rows[0]["dtUpdated"]).ToString(); if((bool)dtCustomFieldsFromDB.Rows[0]["btActive"]) ddlStatus.SelectedValue = "1"; else ddlStatus.SelectedValue = "0"; ViewState["ComponentTypeId"] = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0]["TypeId"]); } arrCFD = _functions.GetCustomFields(true, (int)ViewState["ComponentTypeId"], HttpContext.Current.User.Identity.Name); if(arrCFD.Count > 0) { // filling custom fields in the dtCustomFields table for(j = 0; j < arrCFD.Count; j++) { cfd = (clsCustomFieldsDef)arrCFD[j]; sTypeName = _functions.GetFieldTypeText(cfd.FieldTypeId) + cfd.NumberColumn.ToString(); if(ComponentId == 0) oItem = DBNull.Value; else oItem = dtCustomFieldsFromDB.Rows[0][sTypeName]; switch(cfd.FieldTypeId) { case DBFieldType._nvarchar: if(oItem != DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, oItem, "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "False", "", ""}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "False", "", ""}); break; case DBFieldType._int: if(oItem != DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, oItem, "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "True", cfd.NameText + " must be numeric", "^\\d{0,10}?$"}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "True", cfd.NameText + " must be numeric", "^\\d{0,10}?$"}); break; case DBFieldType._float: if(oItem != DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, oItem, "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "True", cfd.NameText + " must be decimal numeric", "^\\d{0,8}(?:\\.\\d{0,8})?$"}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "True", cfd.NameText + " must be decimal numeric", "^\\d{0,8}(?:\\.\\d{0,8})?$"}); break; case DBFieldType._datetime: if(oItem != DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, ((SqlDateTime)oItem).Value.ToShortDateString(), "False", "False", "False", "False", "True", cfd.Help, "False", "", ""}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "", "False", "False", "False", "False", "True", cfd.Help, "False", "", ""}); break; case DBFieldType._bit: if(oItem != DBNull.Value) { if(((SqlBoolean)oItem) == SqlBoolean.True) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "True", 0, "2000-01-01", "False", "False", "True", "False", "False", cfd.Help, "False", "", ""}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "False", "False", "True", "False", "False", cfd.Help, "False", "", ""}); break; } else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "False", "False", "True", "False", "False", cfd.Help, "False", "", ""}); break; case DBFieldType._ntext: if(oItem != DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, oItem, "2000-01-01", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "False", "", ""}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "2000-01-01", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "False", "", ""}); break; case DBFieldType._sql_variant: dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, (string)dtCustomFieldsFromDB.Rows[0][sTypeName], "2000-01-01", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "False", "", ""}); break; case DBFieldType._lookup: if(oItem != DBNull.Value) { if(cfd.NameLookupTable == "EquipModels") // adding data into DropDownList controls both Make and Model dtCustomFields.Rows.Add(new object []{sTypeName, "Make/Model", "", "False", Convert.ToInt32(oItem), "2000-01-01", "False", "False", "False", "True", "False", cfd.Help, "False", "", ""}); else dtCustomFields.Rows.Add(new object []{sTypeName, "Make/Model", "", "False", "0", "2000-01-01", "False", "False", "False", "True", "False", cfd.Help, "False", "", ""}); } else dtCustomFields.Rows.Add(new object []{sTypeName, "Make/Model", "", "False", "0", "2000-01-01", "False", "False", "False", "True", "False", cfd.Help, "False", "", ""}); break; default: break; } cfd = null; } // binding main datalist ViewState["CustomFields"] = dtCustomFields; repCustomFields.DataSource = new DataView(dtCustomFields); repCustomFields.DataBind(); } else { Session["lastpage"] = ParentPageURL; Session["error"] = _functions.ErrorMessage(102); Response.Redirect("error.aspx", false); } } } catch(Exception ex) { _functions.Log("Application error: \n" + ex.ToString()); Session["lastpage"] = ParentPageURL; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(comp != null) { comp.Dispose(); } } }
/// <summary> /// If the custom fields contain the lookup data then we will show its /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void repComponents_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e) { System.Data.DataRowView drItem = null; object oItem; try { if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.SelectedItem) { dtCustomFields = new DataTable(); dtCustomFields.Columns.Add("ValueName_Comp"); dtCustomFields.Columns.Add("Value_Comp"); dtComponents = (DataTable)ViewState["Components"]; for(int i=0; i< dtComponents.Rows.Count; i++) { drItem = (System.Data.DataRowView)e.Item.DataItem; if(drItem.Row.ItemArray[0].ToString() == dtComponents.Rows[i]["ComponentId"].ToString()) { // getting the custoom fields info for a Component arrCFD = _functions.GetCustomFields(CFDataType.Component, Convert.ToInt32(dtComponents.Rows[i]["TypeId"]), HttpContext.Current.User.Identity.Name); for(int j = 0; j < arrCFD.Count; j++) { cfd = (clsCustomFieldsDef)arrCFD[j]; sTypeName = _functions.GetFieldTypeText(cfd.FieldTypeId) + cfd.NumberColumn.ToString(); oItem = dtComponents.Rows[i][sTypeName]; switch(cfd.FieldTypeId) { case DBFieldType._lookup: switch(cfd.NameLookupTable) { case "EquipModels": if(oItem != DBNull.Value) { mm = new clsMakesModels(); mm.iOrgId = OrgId; mm.iModelId = Convert.ToInt32(oItem); mm.GetModelMakes(); dtCustomFields.Rows.Add(new object []{"Make/Model", mm.sMakeName + "/" + mm.sModelName}); } else dtCustomFields.Rows.Add(new object []{"Make/Model", ""}); break; case "Departments": if(oItem != DBNull.Value) { dep = new clsDepartments(); dep.cAction = "S"; dep.iOrgId = OrgId; dep.iId = Convert.ToInt32(oItem); if(dep.DepartmentDetail() == 0) { dtCustomFields.Rows.Add(new object []{cfd.NameText, dep.sName.Value}); } } else dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); break; case "Locations": if(oItem != DBNull.Value) { loc = new clsLocations(); loc.cAction = "S"; loc.iOrgId = OrgId; loc.iId = Convert.ToInt32(oItem); if(loc.LocationDetail() == 0) { dtCustomFields.Rows.Add(new object []{cfd.NameText, loc.sName.Value}); } } else dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); break; default: break; } break; case DBFieldType._datetime: if(oItem != DBNull.Value) dtCustomFields.Rows.Add(new object []{cfd.NameText, Convert.ToDateTime(oItem).ToShortDateString()}); else dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); break; case DBFieldType._bit: if(oItem != DBNull.Value) if(((SqlBoolean)oItem) == SqlBoolean.True) dtCustomFields.Rows.Add(new object []{cfd.NameText, "Yes"}); else dtCustomFields.Rows.Add(new object []{cfd.NameText, "No"}); else dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); break; default: if(oItem != DBNull.Value) dtCustomFields.Rows.Add(new object []{cfd.NameText, oItem}); else dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); break; } cfd = null; } ((Repeater)e.Item.FindControl("repComponentItem")).DataSource = new DataView(dtCustomFields); ((Repeater)e.Item.FindControl("repComponentItem")).DataBind(); } } } } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = ParentPageURL; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { } }
private void Page_Load(object sender, System.EventArgs e) { int j; bool bVisibleLink; try { OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); if(Request.QueryString["id"] == null) { Session["lastpage"] = "e_list.aspx"; Session["error"] = _functions.ErrorMessage(104); Response.Redirect("error.aspx", false); return; } try { EquipId = Convert.ToInt32(Request.QueryString["id"]); } catch(FormatException fex) { Session["lastpage"] = "e_list.aspx"; Session["error"] = _functions.ErrorMessage(105); Response.Redirect("error.aspx", false); return; } if(!IsPostBack) { hlEdit.NavigateUrl = "e_edit.aspx?id=" + EquipId.ToString(); hlEdit2.NavigateUrl = "e_edit2.aspx?id=" + EquipId.ToString(); hlEditCustom.NavigateUrl = "e_editCustom.aspx?id=" + EquipId.ToString(); hlEditAquis.NavigateUrl = "e_editAquis.aspx?id=" + EquipId.ToString(); hlEditDisp.NavigateUrl = "e_editDisp.aspx?id=" + EquipId.ToString(); hlReport.NavigateUrl = "e_viewEquipAssignmentReport.aspx?id=" + EquipId.ToString(); bVisibleLink = base.CheckPermission("e_editComponent.aspx"); trAddComponent.Visible = bVisibleLink; Session["EquipId"] = EquipId; equip = new clsEquipment(); comp = new clsComponents(); dtCustomFields = new DataTable(); dtCustomFields.Columns.Add("ValueName"); dtCustomFields.Columns.Add("Value"); equip.iUserId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true); equip.iOrgId = OrgId; equip.iId = EquipId; equip.cAction = "S"; // showing a Equipment's main data from fixed fields if(equip.EquipmentDetail() == -1) { Session["lastpage"] = ParentPageURL; Session["error"] = _functions.ErrorMessage(102); Response.Redirect("error.aspx", false); return; } lblEquipment.Text = equip.sEquipId.Value; lblType.Text = equip.sType.Value; lblMakeModel.Text = equip.sMakeModelName.Value; lblYear.Text = equip.iYear.Value.ToString(); lblSerial.Text = equip.sVinSerial.Value; lblFuelCode.Text = equip.sFuelCode.Value; lblPlateNumber.Text = equip.sPlateNumber.Value; lblDepartment.Text = equip.sDeptName.Value; lblLocation.Text = equip.sLocName.Value; lblSpare.Text = equip.bSpare.Value?"Yes":"No"; lblAssignedTo.Text = equip.sEquipOperator.Value; lblAssignTempTo.Text = equip.sTempOperator.Value; // showing a Equipment's Alt data from fixed fields if(equip.EquipmentDetail_Alt() == -1) { Session["lastpage"] = ParentPageURL; Session["error"] = _functions.ErrorMessage(102); Response.Redirect("error.aspx", false); return; } lbPMSched.Text = equip.sPMSched.Value; lbInspection.Text = equip.sInspectSchedule.Value; if(!equip.dmCurrentUnits.IsNull) lbUnits.Text = Convert.ToDouble(equip.dmCurrentUnits.Value).ToString(); // showing an Aquisition information from fixed fields if(equip.EquipmentDetail_Aquis() == -1) { Session["lastpage"] = ParentPageURL; Session["error"] = _functions.ErrorMessage(102); Response.Redirect("error.aspx", false); return; } if(!equip.daInService.IsNull) lbDtInService.Text = equip.daInService.Value.ToShortDateString(); if(!equip.daAquired.IsNull) lbDtAquired.Text = equip.daAquired.Value.ToShortDateString(); lbVchPurOrgContact.Text = equip.sPurOrgContact.Value; if(!equip.curPurAmount.IsNull) lbSmPurAmount.Text = equip.curPurAmount.Value.ToString(); if(!equip.dmPurUnits.IsNull) lbIntPurUnits.Text = Convert.ToDouble(equip.dmPurUnits.Value).ToString(); lbVchPurNotes.Text = equip.sPurNotes.Value; // showing a Disposal info from fixed fields if(equip.EquipmentDetail_Disp() == -1) { Session["lastpage"] = ParentPageURL; Session["error"] = _functions.ErrorMessage(102); Response.Redirect("error.aspx", false); return; } if(!equip.daOutOfService.IsNull) lbDtOutOfService.Text = equip.daOutOfService.Value.ToShortDateString(); if(!equip.daDisposed.IsNull) lbDtDisposed.Text = equip.daDisposed.Value.ToShortDateString(); if(!equip.sDispMethod.IsNull) lbVchDispMethod.Text = equip.sDispMethod.Value; if(!equip.sDispOrgContact.IsNull) lbVchDispOrgContact.Text = equip.sDispOrgContact.Value; if(!equip.curDispAmount.IsNull) lbSmDispAmount.Text = equip.curDispAmount.Value.ToString(); if(!equip.dmDispUnits.IsNull) lbIntDispUnits.Text = Convert.ToDouble(equip.dmDispUnits.Value).ToString(); lbVchDispNotes.Text = equip.sDispNotes.Value; // getting all component's types to dropdownlist comp.iEquipId = EquipId; DataTable dtComponmentAdd = comp.GetComponentTypeList(); if(dtComponmentAdd.Rows.Count > 0) { ddlComponentTypes.DataTextField = "vchName"; ddlComponentTypes.DataValueField = "Id"; ddlComponentTypes.DataSource = new DataView(dtComponmentAdd); ddlComponentTypes.DataBind(); } else { ddlComponentTypes.Items.Add(new ListItem("<none>", "0")); lbAddComponent.Enabled = false; } #region Show Custom Fileds for current equipment // getting the custom fields in the DataList control equip.iId = EquipId; dtCustomFieldsFromDB = equip.EquipmentDetail_CustomFields(null); if(dtCustomFieldsFromDB.Rows.Count > 0) { arrCFD = _functions.GetCustomFields(CFDataType.Equipment, Convert.ToInt32(dtCustomFieldsFromDB.Rows[0]["TypeId"]), HttpContext.Current.User.Identity.Name); if(arrCFD.Count > 0) { // fill custom fields for(j = 0; j < arrCFD.Count; j++) { cfd = (clsCustomFieldsDef)arrCFD[j]; sTypeName = _functions.GetFieldTypeText(cfd.FieldTypeId) + cfd.NumberColumn.ToString(); switch(cfd.FieldTypeId) { case DBFieldType._lookup: switch(cfd.NameLookupTable) { case "EquipModels": if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) { dtCustomFields.Rows.Add(new object []{"Make/Model", ""}); } else { mm = new clsMakesModels(); mm.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); mm.iModelId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]); mm.GetModelMakes(); dtCustomFields.Rows.Add(new object []{"Make/Model", mm.sMakeName + "/" + mm.sModelName}); } break; case "Departments": if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } else { dep = new clsDepartments(); dep.cAction = "S"; dep.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); dep.iId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]); if(dep.DepartmentDetail() == 0) { dtCustomFields.Rows.Add(new object []{cfd.NameText, dep.sName.Value}); } else { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } } break; case "Locations": if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } else { loc = new clsLocations(); loc.cAction = "S"; loc.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); loc.iId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]); if(loc.LocationDetail() == 0) { dtCustomFields.Rows.Add(new object []{cfd.NameText, loc.sName.Value}); } else { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } } break; default: break; } break; case DBFieldType._datetime: if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } else { dtCustomFields.Rows.Add(new object []{cfd.NameText, ((DateTime)dtCustomFieldsFromDB.Rows[0][sTypeName]).ToShortDateString()}); } break; case DBFieldType._bit: if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } else { if(((bool)dtCustomFieldsFromDB.Rows[0][sTypeName]) == true) dtCustomFields.Rows.Add(new object []{cfd.NameText, "Yes"}); else dtCustomFields.Rows.Add(new object []{cfd.NameText, "No"}); } break; default: if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } else { dtCustomFields.Rows.Add(new object []{cfd.NameText, dtCustomFieldsFromDB.Rows[0][sTypeName]}); } break; } cfd = null; } // showing a Equipment's data from custom fields repCustomFields.DataSource = new DataView(dtCustomFields); repCustomFields.DataBind(); comp.iEquipId = EquipId; comp.iOrgId = OrgId; dtComponents = comp.GetComponentsList(); dtComponents.Columns.Add("VisibleLink"); foreach(DataRow _row in dtComponents.Rows) { if(bVisibleLink) { _row["VisibleLink"] = "True"; } else { _row["VisibleLink"] = "False"; } } ViewState["Components"] = dtComponents; repComponents.DataSource = new DataView(dtComponents); repComponents.DataBind(); } else { Session["lastpage"] = ParentPageURL; Session["error"] = _functions.ErrorMessage(102); Response.Redirect("error.aspx", false); } } } #endregion } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = ParentPageURL; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(comp != null) { comp.Dispose(); } if(loc != null) { loc.Dispose(); } if(dep != null) { dep.Dispose(); } if(mm != null) { mm.Dispose(); } if(comp != null) { comp.Dispose(); } if(equip != null) { equip.Dispose(); } } }
private void Page_Load(object sender, System.EventArgs e) { int j; string sTypeName; try { if(Request.QueryString["id"] == null) { Session["lastpage"] = "list.aspx"; Session["error"] = _functions.ErrorMessage(104); Response.Redirect("error.aspx", false); return; } try { EquipId=Convert.ToInt32(Request.QueryString["id"]); } catch(FormatException fex) { Session["lastpage"] = "list.aspx"; Session["error"] = _functions.ErrorMessage(105); Response.Redirect("error.aspx", false); return; } string [,] arrBrdCrumbs = new string [3,2]; arrBrdCrumbs[0,0]="main.aspx"; arrBrdCrumbs[0,1]="Home"; arrBrdCrumbs[1,0]="list.aspx"; arrBrdCrumbs[1,1]="Equipment List"; arrBrdCrumbs[2,0]="view.aspx?id=" + EquipId.ToString(); arrBrdCrumbs[2,1]="Equipment Detail"; PageTitle = "Equipment-Edit Custom Fields"; Header.BrdCrumbs=ParseBreadCrumbs(arrBrdCrumbs,PageTitle); Header.PageTitle=PageTitle; SaveCancelControl.ParentPageURL = ParentPageURL; SourcePageName = "editCustom.aspx.cs"; if(!IsPostBack) { equip = new clsEquipment(); dtCustomFields = new DataTable(); dtCustomFields.Columns.Add("TypeName"); dtCustomFields.Columns.Add("ValueName"); dtCustomFields.Columns.Add("Value_String"); dtCustomFields.Columns.Add("Value_Boolean"); dtCustomFields.Columns.Add("Value_Int"); dtCustomFields.Columns.Add("Value_DateTime"); dtCustomFields.Columns.Add("TB_Visible"); dtCustomFields.Columns.Add("DDL_Visible"); dtCustomFields.Columns.Add("CB_Visible"); dtCustomFields.Columns.Add("MM_Visible"); dtCustomFields.Columns.Add("DT_Visible"); dtCustomFields.Columns.Add("Help"); dtCustomFields.Columns.Add("Val_Visible"); dtCustomFields.Columns.Add("ErrorMessage"); dtCustomFields.Columns.Add("Exp"); equip.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); equip.iId = EquipId; equip.cAction="S"; dtCustomFieldsFromDB = equip.EquipmentDetail_CustomFields(null); if(equip.iId == -1) { Session["lastpage"] = ParentPageURL; Session["error"] = _functions.ErrorMessage(102); Response.Redirect("error.aspx", false); return; } if(dtCustomFieldsFromDB.Rows.Count >0) { // adding data into DropDownList controls // parsing the custom fields in the dtCustomFieldsFromDB table arrCFD = _functions.GetCustomFields(CFDataType.Equipment, Convert.ToInt32(dtCustomFieldsFromDB.Rows[0]["TypeId"]), HttpContext.Current.User.Identity.Name); ViewState["EquipTypeId"] = dtCustomFieldsFromDB.Rows[0]["TypeId"]; if(arrCFD == null) { Session["lastpage"] = ParentPageURL; Session["error"] = _functions.ErrorMessage(114); Response.Redirect("error.aspx", false); return; } // filling custom fields in the dtCustomFields table for(j = 0; j < arrCFD.Count; j++) { cfd = (clsCustomFieldsDef)arrCFD[j]; sTypeName = _functions.GetFieldTypeText(cfd.FieldTypeId) + cfd.NumberColumn.ToString(); switch(cfd.FieldTypeId) { case DBFieldType._nvarchar: if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "False", "", ""}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, dtCustomFieldsFromDB.Rows[0][sTypeName], "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "False", "", ""}); break; case DBFieldType._int: if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "True", cfd.NameText + " must be numeric", "^\\d{0,10}?$"}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, dtCustomFieldsFromDB.Rows[0][sTypeName], "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "True", cfd.NameText + " must be numeric", "^\\d{0,10}?$"}); break; case DBFieldType._float: if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "True", cfd.NameText + " must be decimal numeric", "^\\d{0,8}(?:\\.\\d{0,8})?$"}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, dtCustomFieldsFromDB.Rows[0][sTypeName], "False", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "True", cfd.NameText + " must be decimal numeric", "^\\d{0,8}(?:\\.\\d{0,8})?$"}); break; case DBFieldType._datetime: if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "1970-01-01", "False", "False", "False", "False", "True", cfd.Help, "False", "", ""}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, dtCustomFieldsFromDB.Rows[0][sTypeName], "False", "False", "False", "False", "True", cfd.Help, "False", "", ""}); break; case DBFieldType._bit: if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "False", "False", "True", "False", "False", cfd.Help, "False", "", ""}); else { if(((bool)dtCustomFieldsFromDB.Rows[0][sTypeName]) == true) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "True", 0, "2000-01-01", "False", "False", "True", "False", "False", cfd.Help, "False", "", ""}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "False", 0, "2000-01-01", "False", "False", "True", "False", "False", cfd.Help, "False", "", ""}); } break; case DBFieldType._ntext: if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "2000-01-01", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "False", "", ""}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, (string)dtCustomFieldsFromDB.Rows[0][sTypeName], "2000-01-01", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "False", "", ""}); break; case DBFieldType._sql_variant: if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, "", "2000-01-01", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "False", "", ""}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, (string)dtCustomFieldsFromDB.Rows[0][sTypeName], "2000-01-01", 0, "2000-01-01", "True", "False", "False", "False", "False", cfd.Help, "False", "", ""}); break; case DBFieldType._lookup: if(cfd.NameLookupTable == "EquipModels") { // adding data into DropDownList controls both Make and Model if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, "Make/Model", "", "False", 0, "2000-01-01", "False", "False", "False", "True", "False", cfd.Help, "False", "", ""}); else dtCustomFields.Rows.Add(new object []{sTypeName, "Make/Model", "", "False", Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]), "2000-01-01", "False", "False", "False", "True", "False", cfd.Help, "False", "", ""}); } else { if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, 0, "False", 0, "2000-01-01", "False", "True", "False", "False", "False", cfd.Help, "False", "", ""}); else dtCustomFields.Rows.Add(new object []{sTypeName, cfd.NameText, dtCustomFieldsFromDB.Rows[0][sTypeName], "False", 0, "2000-01-01", "False", "True", "False", "False", "False", cfd.Help, "False", "", ""}); } break; default: break; } cfd = null; } // binding main datalist ViewState["CustomFields"] = dtCustomFields; repCustomFields.DataSource = new DataView(dtCustomFields); repCustomFields.DataBind(); } else { Session["lastpage"] = ParentPageURL; Session["error"] = _functions.ErrorMessage(102); Response.Redirect("error.aspx", false); } } } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = ParentPageURL; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(loc != null) { loc.Dispose(); } if(dep != null) { dep.Dispose(); } if(mm != null) { mm.Dispose(); } if(equip != null) { equip.Dispose(); } } }
private void Page_Load(object sender, System.EventArgs e) { string sTypeName; string sDomenName; string sReportPath; try{ int l_iCount; #region Header Section OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); if(Request.QueryString["id"] == null) { Session["lastpage"] = "main.aspx"; Session["error"] = _functions.ErrorMessage(104); Response.Redirect("error.aspx", false); return; } try { OrderId = Convert.ToInt32(Request.QueryString["id"]); } catch(FormatException fex) { Session["lastpage"] = "main.aspx"; Session["error"] = _functions.ErrorMessage(105); Response.Redirect("error.aspx", false); return; } if((string)Session["PathToViewOrder"] != "Monthly-Daily") l_iCount = 2; else l_iCount = 3; Header.AddJavaScriptFile("/OpenWindows.js"); Header.AddBreadCrumb("Home", "/main.aspx"); switch((string)Session["PathToViewOrder"]) { case "Monthly-Daily": Header.AddBreadCrumb("Monthly Work Orders View", "/wo_showOrdersForMonthly.aspx"); Header.AddBreadCrumb("Daily Work Orders View", "/wo_showOrdersForDaily.aspx"); m_sLastPage = "wo_showOrdersForDaily.aspx"; break; case "Monthly": Header.AddBreadCrumb("Monthly Work Orders View", "/wo_showOrdersForMonthly.aspx"); m_sLastPage = "wo_showOrdersForMonthly.aspx"; break; case "Daily": Header.AddBreadCrumb("Daily Work Orders View", "/wo_showOrdersForDaily.aspx"); m_sLastPage = "wo_showOrdersForDaily.aspx"; break; case "Today": Header.AddBreadCrumb("Work Orders Overview", "/wo_showOrdersForToday.aspx"); m_sLastPage = "wo_showOrdersForToday.aspx"; break; case "Weekly": Header.AddBreadCrumb("Weekly Work Orders View", "/wo_showOrdersForWeekly.aspx"); m_sLastPage = "wo_showOrdersForWeekly.aspx"; break; case "Scheduled": Header.AddBreadCrumb("The Scheduled Orders", "/wo_showUnassignedOrders.aspx"); m_sLastPage = "wo_showUnassignedOrders.aspx"; break; case "Completed": Header.AddBreadCrumb("Completed Work Orders", "/wo_showCompletedOrders.aspx"); m_sLastPage = "wo_showCompletedOrders.aspx"; break; case "EquipWOReport": Header.AddBreadCrumb("Equipment Work Order Report", "/wo_viewEquipWorkOrderReport.aspx"); m_sLastPage = "wo_viewEquipWorkOrderReport.aspx"; break; default: Header.AddBreadCrumb("Work Orders Overview", "/wo_showOrdersForToday.aspx"); m_sLastPage = "wo_showOrdersForToday.aspx"; break; } Response.Cookies["bfp_navigate"].Value = Header.BrdCrumbsSerialization; Response.Cookies["bfp_navigate"].Path = "/"; Response.Cookies["bfp_navigate"].Expires = DateTime.Now.AddYears(1); //Session["BrdCrumbs"] = arrBrdCrumbs; #endregion if(!IsPostBack) { dtCustomFields = new DataTable(); dtCustomFields.Columns.Add("ValueName"); dtCustomFields.Columns.Add("Value"); order = new clsWorkOrders(); user = new clsUsers(); order.cAction = "S"; order.iOrgId = OrgId; order.iId = OrderId; if(order.WorkOrderDetails() == -1) { Session["lastpage"] = m_sLastPage; Session["error"] = _functions.ErrorMessage(120); Response.Redirect("error.aspx", false); return; } #region Processing of the Operation Area hlMainEdit.NavigateUrl = "wo_editWorkOrder.aspx?id=" + OrderId.ToString(); hlCloseOrder.NavigateUrl = "wo_closeWorkOrder.aspx?id=" + OrderId.ToString(); hlOpenOrder.NavigateUrl = "wo_openWorkOrder.aspx?id=" + OrderId.ToString(); hlDeleteOrder.NavigateUrl = "wo_deleteWorkOrder.aspx?id=" + OrderId.ToString(); hlCheckIn.NavigateUrl = "wo_viewCheckIn.aspx?id=" + OrderId.ToString(); hlCheckOut.NavigateUrl = "wo_viewCheckOut.aspx?id=" + OrderId.ToString(); hlTimeLog.NavigateUrl = "wo_updateTimeLog.aspx?id=" + OrderId.ToString(); hlReportedIssues.NavigateUrl = "wo_addRepairs.aspx?id=" + OrderId.ToString() + "&back=view"; hlPMItems.NavigateUrl = "wo_addPreventiveMaintenance.aspx?id=" + OrderId.ToString() + "&back=view"; hlInspections.NavigateUrl = "wo_addInspections.aspx?id=" + OrderId.ToString() + "&back=view"; sReportPath = _functions.GetValueFromConfig("SQLRS.Folder"); hlPrintPartUsed.NavigateUrl = "ReportViewer.aspx?Report=" + sReportPath + "%2fPartsList&OrderId=" + OrderId.ToString() + "&OrgId=" + OrgId.ToString(); hlPrintOrderRequest.NavigateUrl = "ReportViewer.aspx?Report=" + sReportPath + "%2fWorkOrderRequest&OrderId=" + OrderId.ToString() + "&OrgId=" + OrgId.ToString(); hlPrintCompletedOrder.NavigateUrl = "ReportViewer.aspx?Report=" + sReportPath + "%2fCompletedOrder&OrderId=" + OrderId.ToString()+ "&OrgId=" + OrgId.ToString(); hlAddRepair.NavigateUrl = "wo_updateRepair.aspx?mode=Edit&repairid=0&inspectid=0&type=FREE&op=Repair&id=" + OrderId.ToString() + "&itemid=0"; status = (WorkOrderStatus)order.iStatusId.Value; opstatus = order.iOperatorStatusId.IsNull?WorkOrderOperatorStatus.Null:(WorkOrderOperatorStatus)order.iOperatorStatusId.Value; ViewState["status"] = status; ViewState["opstatus"] = opstatus; switch(status) { case WorkOrderStatus.Scheduled: // Scheduled status hlMainEdit.Enabled = true; hlMainEdit.Text = "[Change the Scheduled Date]"; hlReportedIssues.Enabled = true; hlPMItems.Enabled = true; hlInspections.Enabled = true; hlCloseOrder.Enabled = false; hlDeleteOrder.Enabled = true; hlTimeLog.Enabled = false; if(opstatus == WorkOrderOperatorStatus.Checked_In) { // check-in status hlOpenOrder.Enabled = true; } else { // not check-in status hlCheckIn.Enabled = true; } break; case WorkOrderStatus.Open: // Opened status hlMainEdit.Enabled = true; hlReportedIssues.Enabled = true; hlPMItems.Enabled = true; hlInspections.Enabled = true; hlPrintOrderRequest.Enabled = true; hlPrintPartUsed.Enabled = true; hlAddRepair.Enabled = true; lbSaveNotes.Enabled = true; hlTimeLog.Enabled = true; break; case WorkOrderStatus.ReOpened: // ReOpened status hlMainEdit.Enabled = true; hlReportedIssues.Enabled = true; hlPMItems.Enabled = true; hlInspections.Enabled = true; hlPrintOrderRequest.Enabled = true; hlPrintPartUsed.Enabled = true; hlAddRepair.Enabled = true; lbSaveNotes.Enabled = true; hlTimeLog.Enabled = true; break; case WorkOrderStatus.Closed: // Closed Status hlMainEdit.Enabled = true; hlMainEdit.Text = "[Change the Order Dates]"; hlPrintCompletedOrder.Enabled = true; hlPrintPartUsed.Enabled = true; hlTimeLog.Enabled = true; if(opstatus == WorkOrderOperatorStatus.Checked_In) { // check-in status hlCheckOut.Enabled = true; } break; } #endregion #region Processing of the Information Area if(status == WorkOrderStatus.Closed) Session["CurrentDay"] = order.daClosed.Value; else Session["CurrentDay"] = order.daScheduled.Value; lblWorkOrderN.Text = order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString(); lblWOType.Text = order.sType.Value; lblStatus.Text = order.sStatusId.Value; lblOperatorStatus.Text = order.sOperatorStatus.Value; lblStaying.Text = order.bStaying.IsNull?"not defined":(order.bStaying.Value?"Yes":"No"); lblSpare.Text = order.sSpareEquipId.Value; lblTech.Text = order.sTechName.Value; lblOperator.Text = order.sOperatorName.Value; lblDroppedOffBy.Text = order.sDropedOffBy.Value; lblReleasedTo.Text = order.sReleasedTo.Value; lblCleanliness.Text = order.sCleanliness.Value; hlServiceDates.Attributes.Add("onclick", "window.open('wo_viewDates.aspx?id=" + OrderId.ToString() + "', 'popupcal', 'width=350,height=200,left=' + event.screenX + ',top=' + event.screenY + ',scrollbars=no');"); // showing equipment info hlEquipId.Text = order.sEquipId.Value; hlEquipId.NavigateUrl = "e_view.aspx?id=" + order.iEquipId.Value.ToString(); lblType.Text = order.sEquipTypeName.Value; lblMakeModel.Text = order.sEquipMakeModel.Value; lblYear.Text = (order.sEquipYear.Value == "0")?"unknown":order.sEquipYear.Value; lblSerial.Text = order.sEquipVinSerial.Value; lblUnits.Text = Convert.ToDouble(order.dmMileage.Value).ToString(); #endregion #region Processing of the Issues Area order.iTechId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, true); dtPMItems = order.GetWorkOrderPMItems(); if(dtPMItems.Rows.Count > 0) html_tblNonePMItems.Visible = false; else html_tblNonePMItems.Visible = true; repPMItems.DataSource = new DataView(dtPMItems); repPMItems.DataBind(); dtIssues = order.GetWorkOrderReportedIssues(); if(dtIssues.Rows.Count > 0) html_tblNoneIssues.Visible = false; else html_tblNoneIssues.Visible = true; repIssues.DataSource = new DataView(dtIssues); repIssues.DataBind(); dtInspections = order.GetWorkOrderInspections(); if(dtInspections.Rows.Count > 0) html_tblNoneInspections.Visible = false; else html_tblNoneInspections.Visible = true; repInspections.DataSource = new DataView(dtInspections); repInspections.DataBind(); #endregion #region Processing of the Serviced Repairs Area and the Time Log Area ShowRepairList(); #endregion #region Processing of the Notes Area order.iItemId = OrderId; order.iNoteTypeId = (int)NoteTypes.CreationNote; repCreationNotes.DataSource = new DataView(order.GetNotesList()); repCreationNotes.DataBind(); order.iNoteTypeId = (int)NoteTypes.OperatorNote; repOperatorNotes.DataSource = new DataView(order.GetNotesList()); repOperatorNotes.DataBind(); order.iNoteTypeId = (int)NoteTypes.TechnicianNote; repTechNotes.DataSource = new DataView(order.GetNotesList()); repTechNotes.DataBind(); #endregion #region Processing of the Signatures Area order.iDocumentId = OrderId; order.iDocumentTypeId = (int)DocumentTypes.WorkOrderCheckedIn; if(order.GetSignedDocument() != -1) { lblSignCheckInBy.Text = order.sUserName.Value; lblSignCheckInByUnder.Text = order.sUserName.Value; lblSignDateCheckInBy.Text = order.daReportDate.Value.ToShortDateString() + " " + order.daReportDate.Value.ToShortTimeString(); } else { lblSignCheckInBy.Text = " "; } order.iDocumentTypeId = (int)DocumentTypes.WorkOrderReOpened; if(order.GetSignedDocument() != -1) { lblSignOpenedBy.Text = order.sUserName.Value; lblSignOpenedByUnder.Text = order.sUserName.Value; lblSignDateOpenedBy.Text = order.daReportDate.Value.ToShortDateString() + " " + order.daReportDate.Value.ToShortTimeString(); } else { order.iDocumentTypeId = (int)DocumentTypes.WorkOrderOpen; if(order.GetSignedDocument() != -1) { lblSignOpenedBy.Text = order.sUserName.Value; lblSignOpenedByUnder.Text = order.sUserName.Value; lblSignDateOpenedBy.Text = order.daReportDate.Value.ToShortDateString() + " " + order.daReportDate.Value.ToShortTimeString(); } else { lblSignOpenedBy.Text = " "; } } if(status == WorkOrderStatus.Closed) { order.iDocumentTypeId = (int)DocumentTypes.WorkOrderClosed; if(order.GetSignedDocument() != -1) { lblSignClosedBy.Text = order.sUserName.Value; lblSignClosedByUnder.Text = order.sUserName.Value; lblSignDateClosedBy.Text = order.daReportDate.Value.ToShortDateString() + " " + order.daReportDate.Value.ToShortTimeString(); } } if(opstatus == WorkOrderOperatorStatus.Checked_Out) { order.iDocumentTypeId = (int)DocumentTypes.WorkOrderCheckedOut; if(order.GetSignedDocument() != -1) { lblSignCheckOutBy.Text = order.sUserName.Value; lblSignCheckOutByUnder.Text = order.sUserName.Value; lblSignDateCheckOutBy.Text = order.daReportDate.Value.ToShortDateString() + " " + order.daReportDate.Value.ToShortTimeString(); } } #endregion #region Processing of the Custom Fields dtCustomFieldsFromDB = order.WorkOrderDetail_CustomFields(null); if(dtCustomFieldsFromDB.Rows.Count > 0) { arrCFD = _functions.GetCustomFields(CFDataType.WorkOrder, 0, HttpContext.Current.User.Identity.Name); if(arrCFD.Count > 0) { // fill custom fields for(int j = 0; j < arrCFD.Count; j++) { cfd = (clsCustomFieldsDef)arrCFD[j]; sTypeName = _functions.GetFieldTypeText(cfd.FieldTypeId) + cfd.NumberColumn.ToString(); switch(cfd.FieldTypeId) { case DBFieldType._lookup: switch(cfd.NameLookupTable) { case "EquipModels": if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) { dtCustomFields.Rows.Add(new object []{"Make/Model", ""}); } else { mm = new clsMakesModels(); mm.iOrgId = OrgId; mm.iModelId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]); mm.GetModelMakes(); dtCustomFields.Rows.Add(new object []{"Make/Model", mm.sMakeName + "/" + mm.sModelName}); if(mm != null) mm.Dispose(); } break; case "Departments": if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } else { dep = new clsDepartments(); dep.cAction = "S"; dep.iOrgId = OrgId; dep.iId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]); if(dep.DepartmentDetail() == 0) { dtCustomFields.Rows.Add(new object []{cfd.NameText, dep.sName.Value}); } else { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } if(dep != null) dep.Dispose(); } break; case "Locations": if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } else { loc = new clsLocations(); loc.cAction = "S"; loc.iOrgId = OrgId; loc.iId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]); if(loc.LocationDetail() == 0) { dtCustomFields.Rows.Add(new object []{cfd.NameText, loc.sName.Value}); } else { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } if(loc != null) loc.Dispose(); } break; default: break; } break; case DBFieldType._datetime: if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } else { dtCustomFields.Rows.Add(new object []{cfd.NameText, ((DateTime)dtCustomFieldsFromDB.Rows[0][sTypeName]).ToShortDateString()}); } break; case DBFieldType._bit: if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } else { if(((bool)dtCustomFieldsFromDB.Rows[0][sTypeName]) == true) dtCustomFields.Rows.Add(new object []{cfd.NameText, "Yes"}); else dtCustomFields.Rows.Add(new object []{cfd.NameText, "No"}); } break; default: if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } else { dtCustomFields.Rows.Add(new object []{cfd.NameText, dtCustomFieldsFromDB.Rows[0][sTypeName]}); } break; } cfd = null; } // showing a Equipment's data from custom fields repCustomFields.DataSource = new DataView(dtCustomFields); repCustomFields.DataBind(); } } #endregion } } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = m_sLastPage; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(user != null) user.Dispose(); if(order != null) order.Dispose(); } }
private void Page_Load(object sender, System.EventArgs e) { string sTypeName; try { OrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); if(Request.QueryString["id"] == null) { Session["lastpage"] = "main.aspx"; Session["error"] = _functions.ErrorMessage(104); Response.Redirect("error.aspx", false); return; } try { OrderId = Convert.ToInt32(Request.QueryString["id"]); } catch(FormatException fex) { Session["lastpage"] = "main.aspx"; Session["error"] = _functions.ErrorMessage(105); Response.Redirect("error.aspx", false); return; } NextBackControl.BackPage = "wo_addInspections.aspx?id=" + OrderId.ToString(); NextBackControl.BackVisible = true; NextBackControl.NextText = "Open/Finish"; if(!IsPostBack) { hlStart.NavigateUrl = "wo_openWorkOrder.aspx?id=" + OrderId.ToString(); hlInspections.NavigateUrl = "wo_addInspections.aspx?id=" + OrderId.ToString(); hlIssues.NavigateUrl = "wo_addRepairs.aspx?id=" + OrderId.ToString() + "&back=open"; hlPMItems.NavigateUrl = "wo_addPreventiveMaintenance.aspx?id=" + OrderId.ToString() + "&back=preview"; dtCustomFields = new DataTable(); dtCustomFields.Columns.Add("ValueName"); dtCustomFields.Columns.Add("Value"); order = new clsWorkOrders(); order.cAction = "S"; order.iOrgId = OrgId; order.iId = OrderId; if(order.WorkOrderDetails() == -1) { Session["lastpage"] = "wo_addInspections.aspx?id=" + OrderId.ToString(); Session["error"] = _functions.ErrorMessage(120); Response.Redirect("error.aspx", false); return; } if(order.iStatusId.Value != (int)WorkOrderStatus.Scheduled || order.iOperatorStatusId.Value !=(int)WorkOrderOperatorStatus.Checked_In) { Signature.sError = _functions.ErrorMessage(144); NextBackControl.NextEnabled = false; } // showing main info lblWorkOrderN.Text = order.daCreated.Value.ToString("yyyy-MM-dd") + "-" + order.iWorkOrderNumber.Value.ToString(); lblWOType.Text = order.sType.Value; lblStatus.Text = order.sStatusId.Value; lblOperatorStatus.Text = order.sOperatorStatus.Value; lblOperator.Text = order.sOperatorName.Value; lblStaying.Text = order.bStaying.IsNull?"not defined":(order.bStaying.Value?"Yes":"No"); lblSpare.Text = order.sSpareEquipId.Value; lblTech.Text = order.sTechName.Value; lblDroppedOffBy.Text = order.sDropedOffBy.Value; lblArrivalDate.Text = order.daArrival.IsNull?"":order.daArrival.Value.ToLongDateString(); lblScheduledDate.Text = order.daScheduled.Value.ToLongDateString(); hlEquipId.Text = order.sEquipId.Value; hlEquipId.NavigateUrl = "e_view.aspx?id=" + order.iEquipId.Value.ToString(); lblType.Text = order.sEquipTypeName.Value; lblMakeModel.Text = order.sEquipMakeModel.Value; lblYear.Text = (order.sEquipYear.Value == "0")?"unknown":order.sEquipYear.Value; lblUnits.Text = Convert.ToDouble(order.dmMileage.Value).ToString(); // showing issues dsRepairs = order.GetReportedIssueLists(); if(dsRepairs.Tables[0].Rows.Count > 0) { html_tblNoneIssues.Visible = false; } else { html_tblNoneIssues.Visible = true; } repIssues.DataSource = new DataView(dsRepairs.Tables[0]); repIssues.DataBind(); // showing the pm items dwPMItems = new DataView(order.GetPMServicesListForWorkOrder()); dwPMItems.RowFilter = "IsChecked='True'"; if(dwPMItems.Count > 0) { html_tblNonePMItems.Visible = false; } else { html_tblNonePMItems.Visible = true; } repPMItems.DataSource = dwPMItems; repPMItems.DataBind(); // showing the inspections dwInspections = new DataView(order.GetInspectionsListForWorkOrder()); dwInspections.RowFilter = "IsChecked='True'"; if(dwInspections.Count > 0) { html_tblNoneInspections.Visible = false; } else { html_tblNoneInspections.Visible = true; } repInspections.DataSource = dwInspections; repInspections.DataBind(); // showing notes order.iItemId = OrderId; order.iNoteTypeId = (int)NoteTypes.CreationNote; repCreationNotes.DataSource = new DataView(order.GetNotesList()); repCreationNotes.DataBind(); order.iNoteTypeId = (int)NoteTypes.OperatorNote; repOperatorNotes.DataSource = new DataView(order.GetNotesList()); repOperatorNotes.DataBind(); #region Showing custom fields of order on screen dtCustomFieldsFromDB = order.WorkOrderDetail_CustomFields(null); if(dtCustomFieldsFromDB.Rows.Count > 0) { arrCFD = _functions.GetCustomFields(CFDataType.WorkOrder, 0, HttpContext.Current.User.Identity.Name); if(arrCFD.Count > 0) { // fill custom fields for(int j = 0; j < arrCFD.Count; j++) { cfd = (clsCustomFieldsDef)arrCFD[j]; sTypeName = _functions.GetFieldTypeText(cfd.FieldTypeId) + cfd.NumberColumn.ToString(); switch(cfd.FieldTypeId) { case DBFieldType._lookup: switch(cfd.NameLookupTable) { case "EquipModels": if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) { dtCustomFields.Rows.Add(new object []{"Make/Model", ""}); } else { mm = new clsMakesModels(); mm.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); mm.iModelId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]); mm.GetModelMakes(); dtCustomFields.Rows.Add(new object []{"Make/Model", mm.sMakeName + "/" + mm.sModelName}); if(mm != null) mm.Dispose(); } break; case "Departments": if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } else { dep = new clsDepartments(); dep.cAction = "S"; dep.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); dep.iId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]); if(dep.DepartmentDetail() == 0) { dtCustomFields.Rows.Add(new object []{cfd.NameText, dep.sName.Value}); } else { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } if(dep != null) dep.Dispose(); } break; case "Locations": if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } else { loc = new clsLocations(); loc.cAction = "S"; loc.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); loc.iId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]); if(loc.LocationDetail() == 0) { dtCustomFields.Rows.Add(new object []{cfd.NameText, loc.sName.Value}); } else { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } if(loc != null) loc.Dispose(); } break; default: break; } break; case DBFieldType._datetime: if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } else { dtCustomFields.Rows.Add(new object []{cfd.NameText, ((DateTime)dtCustomFieldsFromDB.Rows[0][sTypeName]).ToShortDateString()}); } break; case DBFieldType._bit: if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } else { if(((bool)dtCustomFieldsFromDB.Rows[0][sTypeName]) == true) dtCustomFields.Rows.Add(new object []{cfd.NameText, "Yes"}); else dtCustomFields.Rows.Add(new object []{cfd.NameText, "No"}); } break; default: if(dtCustomFieldsFromDB.Rows[0][sTypeName] == DBNull.Value) { dtCustomFields.Rows.Add(new object []{cfd.NameText, ""}); } else { dtCustomFields.Rows.Add(new object []{cfd.NameText, dtCustomFieldsFromDB.Rows[0][sTypeName]}); } break; } cfd = null; } // showing a Equipment's data from custom fields repCustomFields.DataSource = new DataView(dtCustomFields); repCustomFields.DataBind(); } } #endregion } } catch(Exception ex) { _functions.Log(ex, HttpContext.Current.User.Identity.Name, SourcePageName); Session["lastpage"] = "wo_addInspections.aspx?id=" + OrderId.ToString(); Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(order != null) order.Dispose(); } }
/// <summary> /// Getting the custom fields data from EquipData table /// </summary> /// <param name="bIsComponent">The boolean argument using for defining owner of data: the Equipment or the its component.</param> /// <param name="iTypeId">The integer argument for defining type of data</param> /// <param name="sContext_User_Identity">The Org string</param> /// <returns>Return the array containing data of custom fields in the clsCustomFieldsDef classes</returns> public static ArrayList GetCustomFields(CFDataType cfdDataTypeId, int iTypeId, string sContext_User_Identity) { ArrayList arrCFD = null; clsCustomFieldsDef cfd = null; clsCustFields custfield = null; DataTable dtFields = null; try { custfield = new clsCustFields(); arrCFD = new ArrayList(); custfield.iOrgId = GetUserOrgId(sContext_User_Identity, false); custfield.iDataTypeId = (int)cfdDataTypeId; custfield.iComponentTypeID = (SqlInt32)iTypeId; dtFields = custfield.GetCustFields(); if(dtFields.Rows.Count == 0) { return null; } for(int i = 0; i < dtFields.Rows.Count; i++) { cfd = new clsCustomFieldsDef(); cfd.Id = Convert.ToInt32(dtFields.Rows[i]["Id"]); cfd.NumberColumn = Convert.ToInt32(dtFields.Rows[i]["NumberColumn"]); cfd.Name = Convert.ToString(dtFields.Rows[i]["vchName"]); cfd.NameText = Convert.ToString(dtFields.Rows[i]["vchNameText"]); cfd.NameLookupTable = Convert.ToString(dtFields.Rows[i]["vchNameLookupTable"]); cfd.NameFieldLookup = Convert.ToString(dtFields.Rows[i]["vchNameFieldLookup"]); cfd.Required = Convert.ToBoolean(dtFields.Rows[i]["btRequired"]); cfd.FieldTypeId = (DBFieldType)Convert.ToInt32(dtFields.Rows[i]["intFieldTypeId"]); cfd.Default = Convert.ToString(dtFields.Rows[i]["vchDefault"]); cfd.Help = Convert.ToString(dtFields.Rows[i]["vchHelp"]); arrCFD.Add(cfd); cfd = null; } return arrCFD; } catch(Exception ex) { throw new Exception(ex.Message, ex); } finally { if(custfield != null) { custfield.Dispose(); } } }
private void Page_Load(object sender, System.EventArgs e) { clsCustomFieldsDef cfd = null; int j; try { if(Request.QueryString["id"] == null) { Session["lastpage"] = "list.aspx"; Session["error"] = _functions.ErrorMessage(104); Response.Redirect("error.aspx", false); return; } try { EquipId=Convert.ToInt32(Request.QueryString["id"]); } catch(FormatException fex) { Session["lastpage"] = "list.aspx"; Session["error"] = _functions.ErrorMessage(105); Response.Redirect("error.aspx", false); return; } PageTitle = "Equipment Detail"; string [,] arrBrdCrumbs = new string [2,2]; arrBrdCrumbs[0,0]="main.aspx"; arrBrdCrumbs[0,1]="Home"; arrBrdCrumbs[1,0]="list.aspx"; arrBrdCrumbs[1,1]="Equipment List"; PageTitle = "Equipment Detail"; Header.BrdCrumbs=ParseBreadCrumbs(arrBrdCrumbs,PageTitle); Header.PageTitle=PageTitle; if(!IsPostBack) { Session["EquipId"] = EquipId; equip = new clsEquipment(); comp = new clsComponents(); dtCustomFields = new DataTable(); dtCustomFields.Columns.Add("ValueName"); dtCustomFields.Columns.Add("Value"); equip.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); equip.iId = EquipId; equip.cAction = "S"; // getting a fixed fields in the label controls if(equip.EquipmentDetail() == -1) { Session["lastpage"] = ParentPageURL; Session["error"] = _functions.ErrorMessage(102); Response.Redirect("error.aspx", false); } // showing a Equipment's data from fixed fields lbStatus.Text = equip.sStatus.Value; lbPMSched.Text = equip.sPMSched.Value; lbInspection.Text = equip.sInspect.Value; if(!equip.iCurrentUnits.IsNull) lbUnits.Text = equip.iCurrentUnits.Value.ToString(); if(!equip.daInService.IsNull) lbDtInService.Text = equip.daInService.Value.ToShortDateString(); if(!equip.daAquired.IsNull) lbDtAquired.Text = equip.daAquired.Value.ToShortDateString(); lbVchPurOrgContact.Text = equip.sPurOrgContact.Value; if(!equip.curPurAmount.IsNull) lbSmPurAmount.Text = equip.curPurAmount.Value.ToString(); if(!equip.iPurUnits.IsNull) lbIntPurUnits.Text = equip.iPurUnits.Value.ToString(); lbVchPurNotes.Text = equip.sPurNotes.Value; if(!equip.daOutOfService.IsNull) lbDtOutOfService.Text = equip.daOutOfService.Value.ToShortDateString(); if(!equip.daDisposed.IsNull) lbDtDisposed.Text = equip.daDisposed.Value.ToShortDateString(); if(!equip.sDispMethod.IsNull) lbVchDispMethod.Text = equip.sDispMethod.Value; if(!equip.sDispOrgContact.IsNull) lbVchDispOrgContact.Text = equip.sDispOrgContact.Value; if(!equip.curDispAmount.IsNull) lbSmDispAmount.Text = equip.curDispAmount.Value.ToString(); if(!equip.iDispUnits.IsNull) lbIntDispUnits.Text = equip.iDispUnits.Value.ToString(); lbVchDispNotes.Text = equip.sDispNotes.Value; // getting all component's types to dropdownlist comp.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); ddlComponentTypes.DataTextField = "vchName"; ddlComponentTypes.DataValueField = "Id"; ddlComponentTypes.DataSource = new DataView(comp.GetComponentTypeList()); ddlComponentTypes.DataBind(); // getting the fixed fields in the DataList control dtCustomFieldsFromDB = equip.EquipmentDetail_CustomFields(null); dtCustomFields.Rows.Add(new object []{"Type", dtCustomFieldsFromDB.Rows[0]["TypeName"]}); // getting the custom fields in the DataList control //arrCFD = _functions.CustomFieldsParse(dtCustomFieldsFromDB, Convert.ToInt32(Session["EquipTypeId"])); arrCFD = _functions.GetCustomFields(false, Convert.ToInt32(Session["EquipTypeId"]), HttpContext.Current.User.Identity.Name); if(arrCFD.Count > 0) { // fill custom fields for(j = 0; j < arrCFD.Count; j++) { cfd = (clsCustomFieldsDef)arrCFD[j]; sTypeName = _functions.GetFieldTypeText(cfd.FieldTypeId) + cfd.NumberColumn.ToString(); switch(cfd.FieldTypeId) { case DBFieldType._lookup: switch(cfd.NameLookupTable) { case "EquipModels": mm = new clsMakesModels(); mm.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); mm.iModelId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]); mm.GetModelMakes(); dtCustomFields.Rows.Add(new object []{"Make/Model", mm.sMakeName + "/" + mm.sModelName}); break; case "Departments": dep = new clsDepartments(); dep.cAction = "S"; dep.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); dep.iId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]); if(dep.DepartmentDetail() == 0) { dtCustomFields.Rows.Add(new object []{cfd.NameText, dep.sName.Value}); } break; case "Locations": loc = new clsLocations(); loc.cAction = "S"; loc.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); loc.iId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][sTypeName]); if(loc.LocationDetail() == 0) { dtCustomFields.Rows.Add(new object []{cfd.NameText, loc.sName.Value}); } break; default: break; } break; case DBFieldType._datetime: dtCustomFields.Rows.Add(new object []{cfd.NameText, ((DateTime)dtCustomFieldsFromDB.Rows[0][sTypeName]).ToShortDateString()}); break; case DBFieldType._bit: if(((bool)dtCustomFieldsFromDB.Rows[0][sTypeName]) == true) dtCustomFields.Rows.Add(new object []{cfd.NameText, "Yes"}); else dtCustomFields.Rows.Add(new object []{cfd.NameText, "No"}); break; default: dtCustomFields.Rows.Add(new object []{cfd.NameText, dtCustomFieldsFromDB.Rows[0][sTypeName]}); break; } cfd = null; } // showing a Equipment's data from custom fields repCustomFields.DataSource = new DataView(dtCustomFields); repCustomFields.DataBind(); comp.iEquipId = EquipId; comp.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); dtComponents = comp.GetComponentsList(); ViewState["Components"] = dtComponents; repComponents.DataSource = new DataView(dtComponents); repComponents.DataBind(); } else { Session["lastpage"] = ParentPageURL; Session["error"] = _functions.ErrorMessage(102); Response.Redirect("error.aspx", false); } } } catch(Exception ex) { _functions.Log("Application error: \n" + ex.ToString()); Session["lastpage"] = ParentPageURL; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(comp != null) { comp.Dispose(); } if(loc != null) { loc.Dispose(); } if(dep != null) { dep.Dispose(); } if(mm != null) { mm.Dispose(); } if(comp != null) { comp.Dispose(); } if(equip != null) { equip.Dispose(); } } }
private void Page_Load(object sender, System.EventArgs e) { try { if(Request.QueryString["id"] == null) { Session["lastpage"] = "list.aspx"; Session["error"] = _functions.ErrorMessage(104); Response.Redirect("error.aspx", false); return; } try { EquipId=Convert.ToInt32(Request.QueryString["id"]); } catch(FormatException fex) { Session["lastpage"] = "list.aspx"; Session["error"] = _functions.ErrorMessage(105); Response.Redirect("error.aspx", false); return; } PageTitle = "Reassign Equipment"; string [,] arrBrdCrumbs = new string [3,2]; arrBrdCrumbs[0,0]="main.aspx"; arrBrdCrumbs[0,1]="Home"; arrBrdCrumbs[1,0]="list.aspx"; arrBrdCrumbs[1,1]="Equipment List"; arrBrdCrumbs[2,0]="view.aspx?id="+EquipId; arrBrdCrumbs[2,1]="Equipment Detail"; Header.BrdCrumbs=ParseBreadCrumbs(arrBrdCrumbs,PageTitle); Header.PageTitle="Reassign Equipment"; SaveCancelControl.ParentPageURL=ParentPageURL; if(!IsPostBack) { ViewState["EquipId"] = EquipId; equip = new clsEquipment(); dtCustomFields = new DataTable(); dtCustomFields.Columns.Add("ValueName"); dtCustomFields.Columns.Add("Value"); equip.iOrgId = _functions.GetUserOrgId(HttpContext.Current.User.Identity.Name, false); equip.iId = EquipId; equip.cAction = "S"; dtUsers = equip.GetEquipAssignTo(); if(dtUsers.Rows.Count < 1) { Session["lastpage"] = ParentPageURL; Session["error"] = _functions.ErrorMessage(111); Response.Redirect("error.aspx", false); return; } ddAssignTo.DataTextField = "vchName"; ddAssignTo.DataValueField = "id"; ddAssignTo.DataSource = new DataView(dtUsers); ddAssignTo.DataBind(); ddAssignTo.Items.Insert(0, ""); // getting equipment's data dtCustomFieldsFromDB = equip.EquipmentDetail_CustomFields(null); if(dtCustomFieldsFromDB.Rows.Count > 0) { if(dtCustomFieldsFromDB.Rows[0]["UserName"] == DBNull.Value) lbAssignFrom.Text = ""; else lbAssignFrom.Text = dtCustomFieldsFromDB.Rows[0]["UserName"].ToString(); dtCustomFields.Rows.Add(new object []{"Type", dtCustomFieldsFromDB.Rows[0]["TypeName"]}); // getting the custom fields in the DataList control arrCFD = _functions.GetCustomFields(false, Convert.ToInt32(Session["EquipTypeId"]), HttpContext.Current.User.Identity.Name); if(arrCFD.Count > 0) { // fill custom fields for(int j = 0; j < arrCFD.Count; j++) { cfd = (clsCustomFieldsDef)arrCFD[j]; if(cfd.FieldTypeId == DBFieldType._lookup) { switch(cfd.NameLookupTable) { case "EquipModels": mm = new clsMakesModels(); mm.iOrgId = 1; // later change mm.iModelId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][_functions.GetFieldTypeText(cfd.FieldTypeId) + cfd.NumberColumn.ToString()]); mm.GetModelMakes(); dtCustomFields.Rows.Add(new object []{"Make/Model", mm.sMakeName + "/" + mm.sModelName}); break; case "Departments": dep = new clsDepartments(); dep.cAction = "S"; dep.iOrgId = 1; dep.iId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][_functions.GetFieldTypeText(cfd.FieldTypeId) + cfd.NumberColumn.ToString()]); if(dep.DepartmentDetail() == 0) { dtCustomFields.Rows.Add(new object []{cfd.NameText, dep.sName.Value}); } break; case "Locations": loc = new clsLocations(); loc.cAction = "S"; loc.iOrgId = 1; loc.iId = Convert.ToInt32(dtCustomFieldsFromDB.Rows[0][_functions.GetFieldTypeText(cfd.FieldTypeId) + cfd.NumberColumn.ToString()]); if(loc.LocationDetail() == 0) { dtCustomFields.Rows.Add(new object []{cfd.NameText, loc.sName.Value}); } break; default: break; } } else { dtCustomFields.Rows.Add(new object []{cfd.NameText, dtCustomFieldsFromDB.Rows[0][_functions.GetFieldTypeText(cfd.FieldTypeId) + cfd.NumberColumn.ToString()]}); } cfd = null; } repCustomFields.DataSource = new DataView(dtCustomFields); repCustomFields.DataBind(); } else { Session["lastpage"] = ParentPageURL; Session["error"] = _functions.ErrorMessage(102); Response.Redirect("error.aspx", false); } } else { Session["lastpage"] = ParentPageURL; Session["error"] = _functions.ErrorMessage(102); Response.Redirect("error.aspx", false); } } } catch(Exception ex) { _functions.Log("Application error: \n" + ex.ToString()); Session["lastpage"] = ParentPageURL; Session["error"] = ex.Message; Session["error_report"] = ex.ToString(); Response.Redirect("error.aspx", false); } finally { if(loc != null) { loc.Dispose(); } if(dep != null) { dep.Dispose(); } if(mm != null) { mm.Dispose(); } if(equip != null) { equip.Dispose(); } } }
/// <summary> /// Parsing the data string from EquipData table for defining the custom fields /// The function doesn't using in the application by now. /// </summary> /// <param name="dtInput">The DataTable containing data of one record of EquipData table of database</param> /// <param name="iTypeId">The type of equipment</param> /// <returns>Return the array containing data of custom fields in the clsCustomFieldsDef classes</returns> public static ArrayList CustomFieldsParse(DataTable dtInput, int iTypeId) { int j; ArrayList arrCFD = null; clsCustomFieldsDef cfd = null; clsCustFields custfield = null; try { custfield = new clsCustFields(); arrCFD = new ArrayList(); custfield.cAction = "S"; custfield.iOrgId = 1; // will change // processing nvarchar's fields type for (j = 1; j <= MAXFIELDS.MAX_NVARCHAR; j++) { if (dtInput.Rows[0]["nvarchar" + j.ToString()] != DBNull.Value) { cfd = new clsCustomFieldsDef(); cfd.FieldTypeId = DBFieldType._nvarchar; custfield.iFieldTypeId = (int)DBFieldType._nvarchar; cfd.NumberColumn = j; custfield.iNumberColumn = j; cfd.IsComponent = false; custfield.bitIsComponent = false; cfd.ComponentTypeID = iTypeId; custfield.iComponentTypeID = iTypeId; custfield.CustFieldsEquipment(); cfd.Id = custfield.iId.Value; cfd.Name = custfield.sName.Value; cfd.NameText = custfield.sNameText.Value; cfd.NameLookupTable = custfield.sNameLookupTable.Value; cfd.NameFieldLookup = custfield.sNameFieldLookup.Value; cfd.Required = custfield.bitRequired.Value; cfd.Default = custfield.sDefault.Value; cfd.Help = custfield.sHelp.Value; arrCFD.Add(cfd); cfd = null; } } // processing int's fields type for (j = 1; j <= MAXFIELDS.MAX_INT; j++) { if (dtInput.Rows[0]["int" + j.ToString()] != DBNull.Value) { cfd = new clsCustomFieldsDef(); cfd.FieldTypeId = DBFieldType._int; custfield.iFieldTypeId = (int)DBFieldType._int; cfd.NumberColumn = j; custfield.iNumberColumn = j; cfd.IsComponent = false; custfield.bitIsComponent = false; cfd.ComponentTypeID = iTypeId; custfield.iComponentTypeID = iTypeId; custfield.CustFieldsEquipment(); cfd.Id = (int)custfield.iId; cfd.Name = (string)custfield.sName; cfd.NameText = (string)custfield.sNameText; cfd.NameLookupTable = (string)custfield.sNameLookupTable; cfd.NameFieldLookup = (string)custfield.sNameFieldLookup; cfd.Required = (bool)custfield.bitRequired; cfd.Default = (string)custfield.sDefault; arrCFD.Add(cfd); cfd = null; } } // processing lookup's fields type for (j = 1; j <= MAXFIELDS.MAX_LOOKUP; j++) { if (dtInput.Rows[0]["lookup" + j.ToString()] != DBNull.Value) { cfd = new clsCustomFieldsDef(); cfd.FieldTypeId = DBFieldType._lookup; custfield.iFieldTypeId = (int)DBFieldType._lookup; cfd.NumberColumn = j; custfield.iNumberColumn = j; cfd.IsComponent = false; custfield.bitIsComponent = false; cfd.ComponentTypeID = iTypeId; custfield.iComponentTypeID = iTypeId; custfield.CustFieldsEquipment(); cfd.Id = (int)custfield.iId; cfd.Name = (string)custfield.sName; cfd.NameText = (string)custfield.sNameText; cfd.NameLookupTable = (string)custfield.sNameLookupTable; cfd.NameFieldLookup = (string)custfield.sNameFieldLookup; cfd.Required = (bool)custfield.bitRequired; cfd.Default = (string)custfield.sDefault; arrCFD.Add(cfd); cfd = null; } } // processing float's fields type for (j = 1; j <= MAXFIELDS.MAX_FLOAT; j++) { if (dtInput.Rows[0]["float" + j.ToString()] != DBNull.Value) { cfd = new clsCustomFieldsDef(); custfield.cAction = "S"; custfield.iOrgId = 1; // will change cfd.FieldTypeId = DBFieldType._float; custfield.iFieldTypeId = (int)DBFieldType._float; cfd.NumberColumn = j; custfield.iNumberColumn = j; cfd.IsComponent = false; custfield.bitIsComponent = false; cfd.ComponentTypeID = iTypeId; custfield.iComponentTypeID = iTypeId; custfield.CustFieldsEquipment(); cfd.Id = (int)custfield.iId; cfd.Name = (string)custfield.sName; cfd.NameText = (string)custfield.sNameText; cfd.NameLookupTable = (string)custfield.sNameLookupTable; cfd.NameFieldLookup = (string)custfield.sNameFieldLookup; cfd.Required = (bool)custfield.bitRequired; cfd.Default = (string)custfield.sDefault; arrCFD.Add(cfd); cfd = null; } } // processing datetime's fields type for (j = 1; j <= MAXFIELDS.MAX_DATETIME; j++) { if (dtInput.Rows[0]["datetime" + j.ToString()] != DBNull.Value) { cfd = new clsCustomFieldsDef(); cfd.FieldTypeId = DBFieldType._datetime; custfield.iFieldTypeId = (int)DBFieldType._datetime; cfd.NumberColumn = j; custfield.iNumberColumn = j; cfd.IsComponent = false; custfield.bitIsComponent = false; cfd.ComponentTypeID = iTypeId; custfield.iComponentTypeID = iTypeId; custfield.CustFieldsEquipment(); cfd.Id = (int)custfield.iId; cfd.Name = (string)custfield.sName; cfd.NameText = (string)custfield.sNameText; cfd.NameLookupTable = (string)custfield.sNameLookupTable; cfd.NameFieldLookup = (string)custfield.sNameFieldLookup; cfd.Required = (bool)custfield.bitRequired; cfd.Default = (string)custfield.sDefault; arrCFD.Add(cfd); cfd = null; } } // processing bit's fields type for (j = 1; j <= MAXFIELDS.MAX_BIT; j++) { if (dtInput.Rows[0]["bit" + j.ToString()] != DBNull.Value) { cfd = new clsCustomFieldsDef(); cfd.FieldTypeId = DBFieldType._bit; custfield.iFieldTypeId = (int)DBFieldType._bit; cfd.NumberColumn = j; custfield.iNumberColumn = j; cfd.IsComponent = false; custfield.bitIsComponent = false; cfd.ComponentTypeID = iTypeId; custfield.iComponentTypeID = iTypeId; custfield.CustFieldsEquipment(); cfd.Id = (int)custfield.iId; cfd.Name = (string)custfield.sName; cfd.NameText = (string)custfield.sNameText; cfd.NameLookupTable = (string)custfield.sNameLookupTable; cfd.NameFieldLookup = (string)custfield.sNameFieldLookup; cfd.Required = (bool)custfield.bitRequired; cfd.Default = (string)custfield.sDefault; arrCFD.Add(cfd); cfd = null; } } return(arrCFD); } catch (Exception ex) { throw new Exception(ex.Message); } finally { if (custfield != null) { custfield.Dispose(); } } }
/// <summary> /// Parsing the data string from EquipData table for defining the custom fields /// The function doesn't using in the application by now. /// </summary> /// <param name="dtInput">The DataTable containing data of one record of EquipData table of database</param> /// <param name="iTypeId">The type of equipment</param> /// <returns>Return the array containing data of custom fields in the clsCustomFieldsDef classes</returns> public static ArrayList CustomFieldsParse(DataTable dtInput, int iTypeId) { int j; ArrayList arrCFD = null; clsCustomFieldsDef cfd = null; clsCustFields custfield = null; try { custfield = new clsCustFields(); arrCFD = new ArrayList(); custfield.cAction = "S"; custfield.iOrgId = 1; // will change // processing nvarchar's fields type for(j = 1; j <= MAXFIELDS.MAX_NVARCHAR; j++) { if( dtInput.Rows[0]["nvarchar" + j.ToString()] != DBNull.Value) { cfd = new clsCustomFieldsDef(); cfd.FieldTypeId = DBFieldType._nvarchar; custfield.iFieldTypeId = (int)DBFieldType._nvarchar; cfd.NumberColumn = j; custfield.iNumberColumn = j; cfd.IsComponent = false; custfield.bitIsComponent = false; cfd.ComponentTypeID = iTypeId; custfield.iComponentTypeID = iTypeId; custfield.CustFieldsEquipment(); cfd.Id = custfield.iId.Value; cfd.Name = custfield.sName.Value; cfd.NameText = custfield.sNameText.Value; cfd.NameLookupTable = custfield.sNameLookupTable.Value; cfd.NameFieldLookup = custfield.sNameFieldLookup.Value; cfd.Required = custfield.bitRequired.Value; cfd.Default = custfield.sDefault.Value; cfd.Help = custfield.sHelp.Value; arrCFD.Add(cfd); cfd = null; } } // processing int's fields type for(j = 1; j <= MAXFIELDS.MAX_INT; j++) { if( dtInput.Rows[0]["int" + j.ToString()] != DBNull.Value) { cfd = new clsCustomFieldsDef(); cfd.FieldTypeId = DBFieldType._int; custfield.iFieldTypeId = (int)DBFieldType._int; cfd.NumberColumn = j; custfield.iNumberColumn = j; cfd.IsComponent = false; custfield.bitIsComponent = false; cfd.ComponentTypeID = iTypeId; custfield.iComponentTypeID = iTypeId; custfield.CustFieldsEquipment(); cfd.Id = (int)custfield.iId; cfd.Name = (string)custfield.sName; cfd.NameText = (string)custfield.sNameText; cfd.NameLookupTable = (string)custfield.sNameLookupTable; cfd.NameFieldLookup = (string)custfield.sNameFieldLookup; cfd.Required = (bool)custfield.bitRequired; cfd.Default = (string)custfield.sDefault; arrCFD.Add(cfd); cfd = null; } } // processing lookup's fields type for(j = 1; j <= MAXFIELDS.MAX_LOOKUP; j++) { if( dtInput.Rows[0]["lookup" + j.ToString()] != DBNull.Value) { cfd = new clsCustomFieldsDef(); cfd.FieldTypeId = DBFieldType._lookup; custfield.iFieldTypeId = (int)DBFieldType._lookup; cfd.NumberColumn = j; custfield.iNumberColumn = j; cfd.IsComponent = false; custfield.bitIsComponent = false; cfd.ComponentTypeID = iTypeId; custfield.iComponentTypeID = iTypeId; custfield.CustFieldsEquipment(); cfd.Id = (int)custfield.iId; cfd.Name = (string)custfield.sName; cfd.NameText = (string)custfield.sNameText; cfd.NameLookupTable = (string)custfield.sNameLookupTable; cfd.NameFieldLookup = (string)custfield.sNameFieldLookup; cfd.Required = (bool)custfield.bitRequired; cfd.Default = (string)custfield.sDefault; arrCFD.Add(cfd); cfd = null; } } // processing float's fields type for(j = 1; j <= MAXFIELDS.MAX_FLOAT; j++) { if( dtInput.Rows[0]["float" + j.ToString()] != DBNull.Value) { cfd = new clsCustomFieldsDef(); custfield.cAction = "S"; custfield.iOrgId = 1; // will change cfd.FieldTypeId = DBFieldType._float; custfield.iFieldTypeId = (int)DBFieldType._float; cfd.NumberColumn = j; custfield.iNumberColumn = j; cfd.IsComponent = false; custfield.bitIsComponent = false; cfd.ComponentTypeID = iTypeId; custfield.iComponentTypeID = iTypeId; custfield.CustFieldsEquipment(); cfd.Id = (int)custfield.iId; cfd.Name = (string)custfield.sName; cfd.NameText = (string)custfield.sNameText; cfd.NameLookupTable = (string)custfield.sNameLookupTable; cfd.NameFieldLookup = (string)custfield.sNameFieldLookup; cfd.Required = (bool)custfield.bitRequired; cfd.Default = (string)custfield.sDefault; arrCFD.Add(cfd); cfd = null; } } // processing datetime's fields type for(j = 1; j <= MAXFIELDS.MAX_DATETIME; j++) { if( dtInput.Rows[0]["datetime" + j.ToString()] != DBNull.Value) { cfd = new clsCustomFieldsDef(); cfd.FieldTypeId = DBFieldType._datetime; custfield.iFieldTypeId = (int)DBFieldType._datetime; cfd.NumberColumn = j; custfield.iNumberColumn = j; cfd.IsComponent = false; custfield.bitIsComponent = false; cfd.ComponentTypeID = iTypeId; custfield.iComponentTypeID = iTypeId; custfield.CustFieldsEquipment(); cfd.Id = (int)custfield.iId; cfd.Name = (string)custfield.sName; cfd.NameText = (string)custfield.sNameText; cfd.NameLookupTable = (string)custfield.sNameLookupTable; cfd.NameFieldLookup = (string)custfield.sNameFieldLookup; cfd.Required = (bool)custfield.bitRequired; cfd.Default = (string)custfield.sDefault; arrCFD.Add(cfd); cfd = null; } } // processing bit's fields type for(j = 1; j <= MAXFIELDS.MAX_BIT; j++) { if( dtInput.Rows[0]["bit" + j.ToString()] != DBNull.Value) { cfd = new clsCustomFieldsDef(); cfd.FieldTypeId = DBFieldType._bit; custfield.iFieldTypeId = (int)DBFieldType._bit; cfd.NumberColumn = j; custfield.iNumberColumn = j; cfd.IsComponent = false; custfield.bitIsComponent = false; cfd.ComponentTypeID = iTypeId; custfield.iComponentTypeID = iTypeId; custfield.CustFieldsEquipment(); cfd.Id = (int)custfield.iId; cfd.Name = (string)custfield.sName; cfd.NameText = (string)custfield.sNameText; cfd.NameLookupTable = (string)custfield.sNameLookupTable; cfd.NameFieldLookup = (string)custfield.sNameFieldLookup; cfd.Required = (bool)custfield.bitRequired; cfd.Default = (string)custfield.sDefault; arrCFD.Add(cfd); cfd = null; } } return arrCFD; } catch(Exception ex) { throw new Exception(ex.Message); } finally { if(custfield != null) { custfield.Dispose(); } } }