//public static string getUnitForSelectedServiceItem(string ItemID, string ItemName) //{ // serviceitem sitem = new serviceitem(); // try // { // SqlConnection conn = new SqlConnection(Login.connString); // string query = "select ServiceItemID, Name,Unit" + // " from ViewServiceItem where ServiceItemID = '" + ItemID + "' and Name = '" + ItemName + "'"; // SqlCommand cmd = new SqlCommand(query, conn); // conn.Open(); // SqlDataReader reader = cmd.ExecuteReader(); // try // { // if (reader.Read()) // { // sitem.ServiceItemID = reader.GetString(0); // sitem.Name = reader.GetString(1); // sitem.Unit = reader.GetString(2); // } // } // catch (Exception ex) // { // } // conn.Close(); // } // catch (Exception ex) // { // MessageBox.Show("Error querying Service Item Data"); // } // return sitem.Unit; //} public static ListView getServiceItemListView() { ListView lv = new ListView(); try { lv.View = View.Details; lv.LabelEdit = true; lv.AllowColumnReorder = true; lv.CheckBoxes = true; lv.FullRowSelect = true; lv.GridLines = true; lv.Sorting = System.Windows.Forms.SortOrder.Ascending; ServiceItemsDB sidb = new ServiceItemsDB(); List <serviceitem> SIList = sidb.getFilteredServiceItems("", 6); ////int index = 0; lv.Columns.Add("Select", -2, HorizontalAlignment.Left); lv.Columns.Add("ServiceItem ID", -2, HorizontalAlignment.Left); lv.Columns.Add("ServiceItem Name", -2, HorizontalAlignment.Left); foreach (serviceitem si in SIList) { ListViewItem item1 = new ListViewItem(); item1.Checked = false; item1.SubItems.Add(si.ServiceItemID.ToString()); item1.SubItems.Add(si.Name); lv.Items.Add(item1); } } catch (Exception) { } return(lv); }
public static void fillServiceItemGridViewCombo(DataGridViewComboBoxCell cmb, string CategoryName) { cmb.Items.Clear(); try { ServiceItemsDB serviceitemdb = new ServiceItemsDB(); List <serviceitem> ServItems = serviceitemdb.getServiceItems(); foreach (serviceitem si in ServItems) { if (si.status == 1) { cmb.Items.Add(si.ServiceItemID + "-" + si.Name); } } } catch (Exception ex) { MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error"); } }
public static ListView ProductCodeSelectionView() { ListView lv = new ListView(); try { lv.View = View.Details; lv.LabelEdit = true; lv.AllowColumnReorder = true; lv.CheckBoxes = true; lv.FullRowSelect = true; lv.GridLines = true; lv.Sorting = System.Windows.Forms.SortOrder.Ascending; ServiceItemsDB sidb = new ServiceItemsDB(); List <serviceitem> serviceitems = sidb.getFilteredServiceItems("", 6); ////int index = 0; lv.Columns.Add("Select", -2, HorizontalAlignment.Left); lv.Columns.Add("Item Id", -2, HorizontalAlignment.Left); lv.Columns.Add("Item Name", -2, HorizontalAlignment.Left); lv.Columns.Add("Cat", -2, HorizontalAlignment.Left); lv.Columns.Add("Group", -2, HorizontalAlignment.Left); lv.Columns.Add("Type", -2, HorizontalAlignment.Center); foreach (serviceitem si in serviceitems) { ListViewItem item1 = new ListViewItem(); item1.Checked = false; item1.SubItems.Add(si.ServiceItemID); item1.SubItems.Add(si.Name.ToString()); item1.SubItems.Add(si.Group1CodeDescription.ToString()); item1.SubItems.Add(si.Group2CodeDescription.ToString()); item1.SubItems.Add(si.Group3CodeDescription.ToString()); lv.Items.Add(item1); } } catch (Exception) { } return(lv); }
public static TreeView getServiceItemTreeView() { TreeView tv = new TreeView(); try { tv.CheckBoxes = true; //tv.Location = new System.Drawing.Point(264, 90); //tv.Size = new System.Drawing.Size(332, 161); tv.LabelEdit = true; tv.ShowLines = true; tv.CheckBoxes = true; //tv.CheckBoxes = "leaf"; // tv.sho tv.FullRowSelect = true; ServiceItemsDB sidb = new ServiceItemsDB(); List <serviceitem> Serviceitems = sidb.getFilteredServiceItems("", 6).Where(si => si.status == 1 && si.documentStatus == 99).ToList(); TreeNode tNode; string RootDesc = ""; string SubRootDesc = ""; string SubSubRootDesc = ""; int j = 0; int k = 0; int l = 0; foreach (serviceitem item in Serviceitems) { l++; int n = tv.Nodes.Count; if (item.Group1CodeDescription != RootDesc) { j = 0; k = 0; tNode = tv.Nodes.Add(item.Group1CodeDescription); tv.Nodes[n].Nodes.Add(item.Group2CodeDescription); tv.Nodes[n].Nodes[j].Nodes.Add(item.Group3CodeDescription); tv.Nodes[n].Nodes[j].Nodes[k].Nodes.Add(item.ServiceItemID + "-" + item.Name); RootDesc = item.Group1CodeDescription; SubRootDesc = item.Group2CodeDescription; SubSubRootDesc = item.Group3CodeDescription; } else { if (item.Group2CodeDescription != SubRootDesc) { j = j + 1; k = 0; tv.Nodes[n - 1].Nodes.Add(item.Group2CodeDescription); tv.Nodes[n - 1].Nodes[j].Nodes.Add(item.Group3CodeDescription); tv.Nodes[n - 1].Nodes[j].Nodes[k].Nodes.Add(item.ServiceItemID + "-" + item.Name); SubRootDesc = item.Group2CodeDescription; SubSubRootDesc = item.Group3CodeDescription; } else { if (item.Group3CodeDescription != SubSubRootDesc) { k = k + 1; tv.Nodes[n - 1].Nodes[j].Nodes.Add(item.Group3CodeDescription); tv.Nodes[n - 1].Nodes[j].Nodes[k].Nodes.Add(item.ServiceItemID + "-" + item.Name); SubSubRootDesc = item.Group3CodeDescription; } else { tv.Nodes[n - 1].Nodes[j].Nodes[k].Nodes.Add(item.ServiceItemID + "-" + item.Name); } } } } // MessageBox.Show("Count:" + l); } catch (Exception ex) { MessageBox.Show("Error in TreeView"); } return(tv); }