Пример #1
0
        //Customer List In GridView
        public DataGridView getGridViewForCustomerDetailsList()
        {
            DataGridView grdCust = new DataGridView();

            try
            {
                string[] strColArr = { "CustomerID", "CustomerName", "LedgerType" };
                DataGridViewTextBoxColumn[] colArr =
                {
                    new DataGridViewTextBoxColumn(), 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;
                grdCust.EnableHeadersVisualStyles         = false;
                grdCust.AllowUserToAddRows            = false;
                grdCust.AllowUserToDeleteRows         = false;
                grdCust.BackgroundColor               = System.Drawing.SystemColors.GradientActiveCaption;
                grdCust.BorderStyle                   = System.Windows.Forms.BorderStyle.None;
                grdCust.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
                grdCust.EditMode            = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
                grdCust.ColumnHeadersHeight = 27;
                grdCust.RowHeadersVisible   = false;
                grdCust.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
                DataGridViewCheckBoxColumn colChk = new DataGridViewCheckBoxColumn();
                colChk.Width      = 50;
                colChk.Name       = "Select";
                colChk.HeaderText = "Select";
                colChk.ReadOnly   = false;
                grdCust.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;
                    if (index == 1)
                    {
                        colArr[index].Width = 500;
                    }
                    else
                    {
                        colArr[index].Width = 200;
                    }
                    if (index == 2)
                    {
                        colArr[index].Visible = false;
                    }
                    grdCust.Columns.Add(colArr[index]);
                }

                CustomerDB      cdb      = new CustomerDB();
                List <customer> CustList = cdb.getCustomerList().OrderBy(cust => cust.name).ToList();

                foreach (customer cust in CustList)
                {
                    grdCust.Rows.Add();
                    grdCust.Rows[grdCust.Rows.Count - 1].Cells[strColArr[0]].Value = cust.CustomerID;
                    grdCust.Rows[grdCust.Rows.Count - 1].Cells[strColArr[1]].Value = cust.name;
                    grdCust.Rows[grdCust.Rows.Count - 1].Cells[strColArr[2]].Value = cust.LedgerType;
                }
            }
            catch (Exception ex)
            {
            }

            return(grdCust);
        }
Пример #2
0
        public static DataGridView getGridViewForPayeeDetails()
        {
            DataGridView grdPOPI = new DataGridView();

            try
            {
                string[] strColArr = { "ID", "Name", "StateCode", "Type" };
                DataGridViewTextBoxColumn[] colArr =
                {
                    new DataGridViewTextBoxColumn(), new DataGridViewTextBoxColumn(), 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;

                    //if (index == 1 || index == 3)
                    //    colArr[index].DefaultCellStyle.Format = "dd-MM-yyyy";
                    //if (index == 6)
                    //    colArr[index].Width = 350;
                    //else if (index == 2)
                    //    colArr[index].Width = 100;
                    //else
                    //    colArr[index].Width = 80;
                    //if (index == 5 || index == 11)
                    //    colArr[index].Visible = false;
                    //else
                    //    colArr[index].Visible = true;
                    grdPOPI.Columns.Add(colArr[index]);
                }
                EmployeePostingDB      edb     = new EmployeePostingDB();
                List <employeeposting> EMPList = EmployeePostingDB.getEmployeePostingList();
                foreach (employeeposting emp in EMPList)
                {
                    grdPOPI.Rows.Add();
                    grdPOPI.Rows[grdPOPI.Rows.Count - 1].Cells[strColArr[0]].Value = emp.empID.ToString();
                    grdPOPI.Rows[grdPOPI.Rows.Count - 1].Cells[strColArr[1]].Value = emp.empName;
                    grdPOPI.Rows[grdPOPI.Rows.Count - 1].Cells[strColArr[2]].Value = "";
                    grdPOPI.Rows[grdPOPI.Rows.Count - 1].Cells[strColArr[3]].Value = "Employee";
                }

                CustomerDB cdb = new CustomerDB();
                //List<customer> CustList = cdb.getCustomers("", 6);
                List <customer> CustList = cdb.getCustomerList();
                foreach (customer cust in CustList)
                {
                    grdPOPI.Rows.Add();
                    grdPOPI.Rows[grdPOPI.Rows.Count - 1].Cells[strColArr[0]].Value = cust.CustomerID;
                    grdPOPI.Rows[grdPOPI.Rows.Count - 1].Cells[strColArr[1]].Value = cust.name;
                    grdPOPI.Rows[grdPOPI.Rows.Count - 1].Cells[strColArr[2]].Value = cust.StateName;
                    grdPOPI.Rows[grdPOPI.Rows.Count - 1].Cells[strColArr[3]].Value = "Party";
                }

                OfficeDB      offDb   = new OfficeDB();
                List <office> offList = offDb.getOffices().Where(off => off.status == 1).ToList();
                foreach (office off in offList)
                {
                    grdPOPI.Rows.Add();
                    grdPOPI.Rows[grdPOPI.Rows.Count - 1].Cells[strColArr[0]].Value = off.OfficeID;
                    grdPOPI.Rows[grdPOPI.Rows.Count - 1].Cells[strColArr[1]].Value = off.name;
                    grdPOPI.Rows[grdPOPI.Rows.Count - 1].Cells[strColArr[2]].Value = "";
                    grdPOPI.Rows[grdPOPI.Rows.Count - 1].Cells[strColArr[3]].Value = "Office";
                }
                //BankBranchDB bankDB = new BankBranchDB();
                //List<bankbranch> BankList = bankDB.getBankBranches();
                //foreach (bankbranch bank in BankList)
                //{
                //    grdPOPI.Rows.Add();
                //    grdPOPI.Rows[grdPOPI.Rows.Count - 1].Cells[strColArr[0]].Value = bank.BranchID;
                //    grdPOPI.Rows[grdPOPI.Rows.Count - 1].Cells[strColArr[1]].Value = bank.BranchName;
                //    grdPOPI.Rows[grdPOPI.Rows.Count - 1].Cells[strColArr[2]].Value = "bank";
                //}
            }
            catch (Exception ex)
            {
            }

            return(grdPOPI);
        }
Пример #3
0
        //Customer List In GridViewNew
        public DataGridView getGridViewForCustomerListNew(string ledgerTypes)
        {
            DataGridView grdCust = new DataGridView();

            try
            {
                string[] ledgerTypeArr             = ledgerTypes.Split(Main.delimiter1);
                string[] strColArr                 = { "ID", "Name", "State", "PinCode", "LedgerType" };
                DataGridViewTextBoxColumn[] colArr =
                {
                    new DataGridViewTextBoxColumn(), new DataGridViewTextBoxColumn(), new DataGridViewTextBoxColumn(), 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;
                grdCust.EnableHeadersVisualStyles         = false;
                grdCust.AllowUserToAddRows            = false;
                grdCust.AllowUserToDeleteRows         = false;
                grdCust.BackgroundColor               = System.Drawing.SystemColors.GradientActiveCaption;
                grdCust.BorderStyle                   = System.Windows.Forms.BorderStyle.None;
                grdCust.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
                grdCust.EditMode            = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
                grdCust.ColumnHeadersHeight = 27;
                grdCust.RowHeadersVisible   = false;
                grdCust.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
                DataGridViewCheckBoxColumn colChk = new DataGridViewCheckBoxColumn();
                colChk.Width      = 50;
                colChk.Name       = "Select";
                colChk.HeaderText = "Select";
                colChk.ReadOnly   = false;
                grdCust.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;
                    if (index == 1)
                    {
                        colArr[index].Width = 300;
                    }
                    else if (index == 0)
                    {
                        colArr[index].Width = 80;
                    }
                    else if (index == 2 || index == 3)
                    {
                        colArr[index].Width = 120;
                    }
                    else
                    {
                        colArr[index].Width = 100;
                    }
                    if (index == 4)
                    {
                        colArr[index].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    }
                    grdCust.Columns.Add(colArr[index]);
                }

                CustomerDB      cdb      = new CustomerDB();
                List <customer> CustList = new List <customer>();
                if (ledgerTypes.Length != 0)
                {
                    CustList = cdb.getCustomerList().Where(cust => ledgerTypeArr.Any(x => cust.LedgerType.Contains(x))).OrderBy(cust => cust.name).ToList();
                }
                else
                {
                    CustList = cdb.getCustomerList().Where(cust => cust.LedgerType.Length != 0).OrderBy(cust => cust.name).ToList();
                }
                foreach (customer cust in CustList)
                {
                    grdCust.Rows.Add();
                    grdCust.Rows[grdCust.Rows.Count - 1].Cells[strColArr[0]].Value = cust.CustomerID;
                    grdCust.Rows[grdCust.Rows.Count - 1].Cells[strColArr[1]].Value = cust.name;
                    grdCust.Rows[grdCust.Rows.Count - 1].Cells[strColArr[2]].Value = cust.StateName;
                    grdCust.Rows[grdCust.Rows.Count - 1].Cells[strColArr[3]].Value = cust.PinCode;
                    string ldg = cust.LedgerType.Remove(cust.LedgerType.LastIndexOf(Main.delimiter1));
                    grdCust.Rows[grdCust.Rows.Count - 1].Cells[strColArr[4]].Value = ldg.Replace(Main.delimiter1, '/');
                    //grdCust.Rows[grdCust.Rows.Count - 1].Cells[strColArr[2]].Value = string.Join("/",ldg.Split(Main.delimiter1));
                }
            }
            catch (Exception ex)
            {
            }

            return(grdCust);
        }