//public static void fillStockItemCombo(System.Windows.Forms.ComboBox cmb, string CategoryName) //{ // cmb.Items.Clear(); // try // { // StockItemDB stockitemdb = new StockItemDB(); // List<stockitem> StockItems = stockitemdb.getStockItems(); // foreach (stockitem si in StockItems) // { // //if (CategoryName.Length > 0 && CategoryName != si.Category) // //{ // // continue; // //} // if (si.status == 1) // { // cmb.Items.Add(si.StockItemID + "-" + si.Name); // } // } // } // catch (Exception ex) // { // MessageBox.Show(this.ToString() + "-"+ System.Reflection.MethodBase.GetCurrentMethod().Name+"() : Error"); // } //} //public static void fillStockItemGridViewCombo(DataGridViewComboBoxCell cmb, string CategoryName) //{ // cmb.Items.Clear(); // try // { // StockItemDB stockitemdb = new StockItemDB(); // List<stockitem> StockItems = stockitemdb.getStockItems(); // foreach (stockitem si in StockItems) // { // //if (CategoryName.Length > 0 && CategoryName != si.Category) // //{ // // continue; // //} // if (si.status == 1) // { // cmb.Items.Add(si.StockItemID + "-" + si.Name); // } // } // } // catch (Exception ex) // { // MessageBox.Show(this.ToString() + "-"+ System.Reflection.MethodBase.GetCurrentMethod().Name+"() : Error"); // } //} public static ListView getAccountCodeListView() { 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; AccountCodeDB ACDb = new AccountCodeDB(); List <accountcode> acList = ACDb.getFilteredAccountDetails("", 6); ////int index = 0; lv.Columns.Add("Select", -2, HorizontalAlignment.Left); lv.Columns.Add("Account code", -2, HorizontalAlignment.Left); lv.Columns.Add("Account Name", -2, HorizontalAlignment.Left); foreach (accountcode ac in acList) { ListViewItem item1 = new ListViewItem(); item1.Checked = false; item1.SubItems.Add(ac.AccountCode); item1.SubItems.Add(ac.Name.ToString()); lv.Items.Add(item1); } } catch (Exception ex) { MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error"); } return(lv); }
public static DataGridView getGridViewForAccountCode() { DataGridView grdPOPI = new DataGridView(); try { string[] strColArr = { "AccountCode", "AccountName" }; DataGridViewTextBoxColumn[] colArr = { new DataGridViewTextBoxColumn(), new DataGridViewTextBoxColumn() }; DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle(); dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle1.BackColor = System.Drawing.Color.LightSeaGreen; dataGridViewCellStyle1.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; grdPOPI.EnableHeadersVisualStyles = false; grdPOPI.AllowUserToAddRows = false; grdPOPI.AllowUserToDeleteRows = false; grdPOPI.BackgroundColor = System.Drawing.SystemColors.GradientActiveCaption; grdPOPI.BorderStyle = System.Windows.Forms.BorderStyle.None; grdPOPI.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; grdPOPI.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter; grdPOPI.ColumnHeadersHeight = 27; grdPOPI.RowHeadersVisible = false; grdPOPI.SelectionMode = DataGridViewSelectionMode.FullRowSelect; DataGridViewCheckBoxColumn colChk = new DataGridViewCheckBoxColumn(); colChk.Width = 50; colChk.Name = "Select"; colChk.HeaderText = "Select"; colChk.ReadOnly = false; grdPOPI.Columns.Add(colChk); foreach (string str in strColArr) { int index = Array.IndexOf(strColArr, str); colArr[index].Name = str; colArr[index].HeaderText = str; colArr[index].ReadOnly = true; grdPOPI.Columns.Add(colArr[index]); } AccountCodeDB ACDb = new AccountCodeDB(); List <accountcode> acList = ACDb.getAccountDetailsList(); foreach (accountcode acc in acList) { grdPOPI.Rows.Add(); grdPOPI.Rows[grdPOPI.Rows.Count - 1].Cells[strColArr[0]].Value = acc.AccountCode; grdPOPI.Rows[grdPOPI.Rows.Count - 1].Cells[strColArr[1]].Value = acc.Name; } } catch (Exception ex) { } return(grdPOPI); }