Exemplo n.º 1
0
        private void gxAddEdit1_EditClick(object sender, EventArgs e)
        {
            if (gxLopGiaoLyList1.CurrentRow == null || (gxLopGiaoLyList1.CurrentRow.DataRow as DataRowView) == null)
            {
                return;
            }
            frmLopGiaoLyList frm = new frmLopGiaoLyList();

            frm.Operation = GxOperation.EDIT;
            DataRow row = (gxLopGiaoLyList1.CurrentRow.DataRow as DataRowView).Row;

            frm.Id        = (int)row["MaLop"];
            frm.IDKhoi    = id;
            frm.NamGiaoLy = Convert.ToInt32(cbNam.SelectedItem.Text);
            frm.AssignControlData();
            if (frm.ShowDialog() == DialogResult.OK)
            {
                if (frm.DataReturn != null)
                {
                    DataTable tbl = Memory.GetData(string.Concat("SELECT * FROM LopGiaoLy WHERE MaLop=" + frm.DataReturn["MaLop"].ToString()));
                    if (Memory.ShowError())
                    {
                        return;
                    }
                    if (tbl != null && tbl.Rows.Count > 0)
                    {
                        foreach (DataColumn col in tbl.Columns)
                        {
                            if (row.Table.Columns.Contains(col.ColumnName))
                            {
                                row[col.ColumnName] = tbl.Rows[0][col.ColumnName];
                            }
                        }

                        string    sqlGiaoLyVien = "select giaolyvien.magiaodan,giaodan.tenthanh,giaodan.hoten from giaolyvien inner join giaodan on giaolyvien.magiaodan=giaodan.magiaodan where giaolyvien.malop =" + frm.Id.ToString();
                        DataTable tblglv        = Memory.GetData(sqlGiaoLyVien);
                        if (tblglv.Rows.Count > 0)
                        {
                            sqlGiaoLyVien = "";
                            foreach (DataRow drglv in tblglv.Rows)
                            {
                                //sqlGiaoLyVien += Memory.GetName(drglv["HoTen"].ToString()) + " - ";
                                sqlGiaoLyVien += drglv["HoTen"].ToString() + ", ";
                            }

                            sqlGiaoLyVien     = sqlGiaoLyVien.Substring(0, sqlGiaoLyVien.Length - 2);
                            row["GiaoLyVien"] = sqlGiaoLyVien;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void gxAddEdit1_AddClick(object sender, EventArgs e)
        {
            frmLopGiaoLyList frm = new frmLopGiaoLyList();

            frm.IDKhoi    = this.id;
            frm.NamGiaoLy = Convert.ToInt32(cbNam.SelectedItem.Text);
            if (frm.ShowDialog() == DialogResult.OK)
            {
                if (frm.DataReturn != null)
                {
                    DataTable tbl = Memory.GetData(string.Concat("SELECT * FROM LopGiaoLy WHERE MaLop=" + frm.DataReturn["MaLop"].ToString()));
                    tbl.Columns.Add("GiaoLyVien", System.Type.GetType("System.String"));
                    foreach (DataRow dr in tbl.Rows)
                    {
                        string    sqlGiaoLyVien = "select giaolyvien.magiaodan,giaodan.tenthanh,giaodan.hoten from giaolyvien inner join giaodan on giaolyvien.magiaodan=giaodan.magiaodan where giaolyvien.malop =" + dr["malop"].ToString();
                        DataTable tblglv        = Memory.GetData(sqlGiaoLyVien);
                        if (tblglv.Rows.Count > 0)
                        {
                            sqlGiaoLyVien = "";
                            foreach (DataRow drglv in tblglv.Rows)
                            {
                                //Khoan modify start
                                //sqlGiaoLyVien += Memory.GetName(drglv["HoTen"].ToString()) + " - ";
                                sqlGiaoLyVien += drglv["HoTen"].ToString() + ", ";
                                //Khoan modify end
                            }

                            sqlGiaoLyVien    = sqlGiaoLyVien.Substring(0, sqlGiaoLyVien.Length - 2);
                            dr["GiaoLyVien"] = sqlGiaoLyVien;
                        }
                    }
                    if (tbl != null && tbl.Rows.Count > 0)
                    {
                        DataTable sourceTbl = (DataTable)gxLopGiaoLyList1.DataSource;
                        if (sourceTbl != null)
                        {
                            //view giao ly vien
                            string    sqlGLV = "select giaolyvien.magiaodan,giaodan.tenthanh,giaodan.hoten from giaolyvien inner join giaodan on giaolyvien.magiaodan=giaodan.magiaodan where giaolyvien.malop =" + frm.DataReturn["MaLop"].ToString();
                            DataTable tblglv = Memory.GetData(sqlGLV);
                            if (tblglv.Rows.Count > 0)
                            {
                                sqlGLV = "";
                                foreach (DataRow drglv in tblglv.Rows)
                                {
                                    //Khoan modify start
                                    //sqlGLV += Memory.GetName(drglv["HoTen"].ToString()) + " - ";
                                    sqlGLV += drglv["HoTen"].ToString() + ", ";
                                    //Khoan modify end
                                }

                                sqlGLV = sqlGLV.Substring(0, sqlGLV.Length - 2);
                                frm.DataReturn.Table.Columns.Add("GiaoLyVien", System.Type.GetType("System.String"));
                                frm.DataReturn["GiaoLyVien"] = sqlGLV;
                            }
                            sourceTbl.ImportRow(frm.DataReturn);
                            gxLopGiaoLyList1.FindAll(gxLopGiaoLyList1.RootTable.Columns[0], Janus.Windows.GridEX.ConditionOperator.Equal, frm.DataReturn["MaLop"]);
                        }
                        else
                        {
                            gxLopGiaoLyList1.DataSource = tbl;
                        }
                    }
                }
            }
        }