private void btn_markActive_Click(object sender, EventArgs e) { model = CommonOps.ToggleFE_ActiveStatus(model); MessageBox.Show(model.FullName + " Active status has been set to " + model.Active); lstFE_Refresh(); fillTextBoxes(); }
public static void ConvertFEListToXML() { List <AssignmentModel> assignments = GlobalConfig.Connection.Assignments_GetAll(); { int assignmentID = 0; foreach (var assignment in assignments) { List <FE_Model> feList = new List <FE_Model>(); assignmentID = assignment.ID; int[] feIDs = new int[] { assignment.FE1ID, assignment.FE2ID, assignment.FE3ID }; for (int i = 0; i < feIDs.Length; i++) { if (feIDs[i] > 0) { FE_Model fe = GlobalConfig.Connection.FE_GetByID(feIDs[i])[0]; if (fe != null) { feList.Add(fe); } } } if (feList.Count > 0) { string xmlData = Serialization.SerializeToXml <List <FE_Model> >(feList); GlobalConfig.Connection.Assignments_FEListXMLUpdateByID(assignmentID, xmlData); } feList = null; } } }
/// <summary> /// Removes assigned FE's from FE list, leaving only available ones /// </summary> /// <param name="RID_List"></param> /// <returns></returns> private static List <FE_Model> RemoveAssignedFEs(List <string> RID_List) { //List<FE_Model> availableFE = GlobalConfig.Connection.FE_GetAllActive(); List <FE_Model> availableFE = GlobalConfig.Connection.GetItemByColumn <FE_Model>("tblFE", "Active", "", 1); foreach (string RID in RID_List) { //Get assignment info List <AssignmentTableModel> feXML_List = GlobalConfig.Connection.GetItemByColumn <AssignmentTableModel> ("tblAssignments", "RequestID", RID, -1); if (feXML_List.Count > 0) { string feXML = feXML_List[0].FE_ListXML; List <int> FEs = Serialization.DeserializeToList <List <int> >(feXML); foreach (int FE in FEs) { try { FE_Model toReomve = availableFE.Where(x => x.ID == FE).Single(); availableFE.Remove(toReomve); } catch (Exception) { } } } } return(availableFE); }
private void lst_FieldEngineer_SelectedIndexChanged(object sender, EventArgs e) { if (!formloading) { model = (FE_Model)lst_FieldEngineer.SelectedItem; fillTextBoxes(); } }
public frmFE() { model = new FE_Model(); InitializeComponent(); makeFEList(); fillRegionCombo(); formloading = false; bool active = true; bool inactive = false; string active1 = active.ToString(); string inactive1 = inactive.ToString(); }
private void initList() { var FE1 = new FE_Model() { FirstName = "Skip", LastName = "Dougherty" }; var FE2 = new FE_Model() { FirstName = "Chris", LastName = "Combs" }; _Models.Add(FE1); _Models.Add(FE2); }
private string collectLeads() { string xmlString = ""; if (!dataLoading) { foreach (var item in lst_FELead.SelectedItems) { FE_Model lead = (FE_Model)item; LeadFE.Add(lead.FirstName); } xmlString = Serialization.SerializeToXml <List <string> >(LeadFE); } return(xmlString); }
private static string makeFEList(Hashtable table, string fE_ListXML) { string names = ""; if (fE_ListXML != null) { List <int> FE_IDs = Serialization.DeserializeToList <List <int> >(fE_ListXML); foreach (var fe in FE_IDs) { FE_Model model = (FE_Model)table[fe]; names += model.FullName; } } return(names); }
private void btnFE_Add_Click(object sender, EventArgs e) { FE_Model model = new FE_Model(); model.FirstName = txtFE_FirstName.Text; model.LastName = txtFE_LastName.Text; model.ManagerID = txtFE_ManagerID.Text; model.Region = txtFE_Region.Text; model.Phone = txtFE_Phone.Text; model.EMail = txtFE_Email.Text; model.Active = bool.Parse(txtFE_Active.Text); GlobalConfig.Connection.FE_CRUD(model, 'C'); MessageBox.Show(model.FullName + " has been added"); lstFE_Refresh(); }
public void FE_CRUD(FE_Model model, char action) { using (IDbConnection connection = new SqlConnection(GlobalConfig.ConnString(db))) { var p = new DynamicParameters(); p.Add("@Action", action, DbType.String); p.Add("@ID", model.ID, DbType.Int32); p.Add("@FirstName", model.FirstName, DbType.String); p.Add("@LastName", model.LastName, DbType.String); p.Add("@ManagerID", model.ManagerID, DbType.String); p.Add("@Region", model.Region, DbType.String); p.Add("@Phone", model.Phone, DbType.String); p.Add("@Email", model.EMail, DbType.String); p.Add("@Active", model.Active, DbType.Boolean); connection.Execute("dbo.spFE_CRUD", p, commandType: CommandType.StoredProcedure); } }
public static FE_Model ToggleFE_ActiveStatus(FE_Model model) { GlobalConfig.Connection.ToggleActiveStatus("tblFE", "Active", model.ID, "ID"); model.Active = !model.Active; return(model); }
private static string makeListFromXML(string ListXML, ListType listType) { List <int> IDs = new List <int>(); Hashtable table = new Hashtable(); IDs = Serialization.DeserializeToList <List <int> >(ListXML); string listData = ""; switch (listType) { case ListType.FE: List <FE_Model> feList = GlobalConfig.Connection.GenericGetAll <FE_Model>("tblFE", "LastName"); foreach (var fe in feList) { table.Add(fe.ID, fe); } if (IDs != null) { foreach (var item in IDs) { FE_Model data = (FE_Model)table[item]; if (data != null) { listData += data.FullName + " / "; } } } break; case ListType.Product: List <ProductModel> productList = GlobalConfig.Connection.GenericGetAll <ProductModel>("tblProducts", "Product"); foreach (var product in productList) { table.Add(product.ID, product); } if (IDs != null) { foreach (var item in IDs) { ProductModel data = (ProductModel)table[item]; if (data != null) { listData += data.Product + " / "; } } } break; default: break; } string returnData = ""; if (listData.Length > 3) { returnData = listData.Substring(0, listData.Length - 3); } return(returnData); }
private List <FieldSearchModel> collectSearchTerms() { List <FieldSearchModel> list = new List <FieldSearchModel>(); FieldSearchModel model = new FieldSearchModel(); foreach (Control ctl in this.Controls) { string ctlname = ctl.Name; string[] tagArray = null; if (ctl.Tag != null) { tagArray = ctl.Tag.ToString().Split('|'); } if (ctl.Text != "") { switch (ctl?.GetType().Name) { case "DateTimePicker": DateTimePicker dtp = ctl as DateTimePicker; FieldSearchModel fsm = new FieldSearchModel(); if (dtp.Format != DateTimePickerFormat.Custom) { fsm.FieldName = tagArray[1]; fsm.FieldValue = dtp.Text; list.Add(fsm); } break; case "TextBox": case "RichTextBox": fsm = new FieldSearchModel(); fsm.FieldName = tagArray[1]; fsm.FieldValue = ctl.Text; list.Add(fsm); break; case "ListBox": switch (ctl.Name) { case "lstFE": ListBox listBox = ctl as ListBox; foreach (FE_Model fe in listBox.SelectedItems) { fsm = new FieldSearchModel(); FE_Model fE_Model = fe as FE_Model; fsm.FieldName = "FE_ListXML"; fsm.FieldValue = fE_Model.ID.ToString(); list.Add(fsm); } break; case "lstTopics": // ListBox listBoxTopics = ctl as ListBox; // foreach (ProductModel prod in listBoxTopics.SelectedItems) // { // fsm = new FieldSearchModel(); // ProductModel productModel = prod as ProductModel; // fsm.FieldName = "ProductListXML"; // fsm.FieldValue = prod.ID.ToString(); // list.Add(fsm); break; default: break; } break; case "ComboBox": switch (ctl.Name) { case "cboMSO": { MSO_Model mso = cboMSO.SelectedItem as MSO_Model; int mso_ID = mso.ID; fsm = new FieldSearchModel(); fsm.FieldName = "MSO_ID"; fsm.FieldValue = mso_ID.ToString(); list.Add(fsm); } break; case "cboActivity": { ActivityModel activity = cboActivity.SelectedItem as ActivityModel; int activity_ID = activity.ID; fsm = new FieldSearchModel(); fsm.FieldName = "Activity_ID"; fsm.FieldValue = activity_ID.ToString(); list.Add(fsm); } break; case "cboRequestor": { RequestorModel requestor = cboRequestor.SelectedItem as RequestorModel; int requestor_ID = requestor.ID; fsm = new FieldSearchModel(); fsm.FieldName = "Requestor"; fsm.FieldValue = requestor_ID.ToString(); list.Add(fsm); } break; default: break; } break; default: break; } } } return(list); }