Exemplo n.º 1
0
        private void frmThongTin_Load(object sender, EventArgs e)
        {
            //Connection objConn = new Connection();
            IDataReader DataReader = null;

            //SqlConnection SqlConn = Connection.Instance.GetSqlConnection();
            //using (SqlConnection SqlConn = objConn.GetSqlConnection())
            //{
            try
            {
                GtidCommand SqlComm = new GtidCommand("Select * From tbl_ThongTin", ConnectionUtil.Instance.GetConnection());
                SqlComm.CommandType = CommandType.Text;
                //if (!(SqlConn.State == ConnectionState.Open)) SqlConn.Open();
                DataReader = SqlComm.ExecuteReader();
                if (DataReader.Read())
                {
                    txtTenDoanhNghiep.Text = DataReader["TenDoanhNghiep"].ToString();
                    txtDiaChi.Text         = DataReader["DiaChi"].ToString();
                    txtVPGiaoDich.Text     = DataReader["VPGiaoDich"].ToString();
                    txtDienThoai.Text      = DataReader["DienThoai"].ToString();
                    txtFax.Text            = DataReader["Fax"].ToString();
                    txtEmail.Text          = DataReader["Email"].ToString();
                    txtWebsite.Text        = DataReader["Website"].ToString();
                    txtMaSoThue.Text       = DataReader["MaSoThue"].ToString();
                    txtSoTaiKhoan.Text     = DataReader["SoTaiKhoan"].ToString();
                    txtNganHang.Text       = DataReader["NganHang"].ToString();
                    txtMota.Text           = DataReader["MoTa"].ToString();
                }
                else
                {
                    txtTenDoanhNghiep.Text = "";
                    txtDiaChi.Text         = "";
                    txtVPGiaoDich.Text     = "";
                    txtDienThoai.Text      = "";
                    txtFax.Text            = "";
                    txtEmail.Text          = "";
                    txtWebsite.Text        = "";
                    txtMaSoThue.Text       = "";
                    txtSoTaiKhoan.Text     = "";
                    txtNganHang.Text       = "";
                    txtMota.Text           = "";
                }
            }
            catch
            {
            }
            finally
            {
                DataReader.Close();
                //if (!(SqlConn.State == ConnectionState.Closed)) SqlConn.Close();
            }
            //}
        }
Exemplo n.º 2
0
        private void frmHT_ThemNhomNSD_Load(object sender, EventArgs e)
        {
            dgvGroupList.ReadOnly           = true;
            dgvGroupList.AllowUserToAddRows = false;

            dgvGroupList.AutoSizeRowsMode         = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
            dgvGroupList.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Raised;
            dgvGroupList.CellBorderStyle          = DataGridViewCellBorderStyle.Single;
            dgvGroupList.GridColor         = SystemColors.ActiveBorder;
            dgvGroupList.RowHeadersVisible = false;
            dgvGroupList.RowHeadersVisible = false;

            dgvGroupList.Rows.Clear();
            dgvGroupList.Columns.Clear();

            DataGridViewTextBoxColumn colSTT = new DataGridViewTextBoxColumn();

            colSTT.Name       = "STT";
            colSTT.HeaderText = "STT";
            colSTT.SortMode   = DataGridViewColumnSortMode.NotSortable;
            colSTT.Width      = 50;
            colSTT.ReadOnly   = true;
            colSTT.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            colSTT.DataPropertyName           = "STT";
            dgvGroupList.Columns.Add(colSTT);

            DataGridViewTextBoxColumn colId = new DataGridViewTextBoxColumn();

            colId.Name       = "Id";
            colId.HeaderText = "Id";
            colId.SortMode   = DataGridViewColumnSortMode.NotSortable;
            colId.Width      = 40;
            colId.ReadOnly   = true;
            colId.Visible    = false;
            colId.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            colId.DataPropertyName           = "IdNhomNguoiDung";
            dgvGroupList.Columns.Add(colId);

            DataGridViewTextBoxColumn colMaNhom = new DataGridViewTextBoxColumn();

            colMaNhom.Name       = "MaNhom";
            colMaNhom.HeaderText = "Mã nhóm";
            colMaNhom.ValueType  = typeof(string);
            colMaNhom.SortMode   = DataGridViewColumnSortMode.Automatic;
            colMaNhom.Width      = 100;
            colMaNhom.ReadOnly   = true;
            colMaNhom.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            colMaNhom.DataPropertyName           = "MaNhom";
            dgvGroupList.Columns.Add(colMaNhom);

            DataGridViewTextBoxColumn colTenNhom = new DataGridViewTextBoxColumn();

            colTenNhom.Name       = "TenNhom";
            colTenNhom.HeaderText = "Tên nhóm";
            colTenNhom.ValueType  = typeof(string);
            colTenNhom.SortMode   = DataGridViewColumnSortMode.Automatic;
            colTenNhom.Width      = 208;
            colTenNhom.ReadOnly   = true;
            colTenNhom.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            colTenNhom.DataPropertyName           = "TenNhom";
            dgvGroupList.Columns.Add(colTenNhom);

            DataGridViewCheckBoxColumn colSuDung = new DataGridViewCheckBoxColumn();

            colSuDung.Name       = "SuDung";
            colSuDung.HeaderText = "Sử dụng";
            colSuDung.Width      = 80;
            colSuDung.ReadOnly   = true;
            colSuDung.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            colSuDung.DataPropertyName           = "SuDung";
            dgvGroupList.Columns.Add(colSuDung);

            dgvGroupList.Columns[1].Visible = false;
            dgvGroupList.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dgvGroupList.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            dgvGroupList.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;

            dgvGroupList.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dgvGroupList.MultiSelect   = false;

            dgvGroupList.RowTemplate.Height = 35;
            dgvGroupList.ColumnHeadersDefaultCellStyle.Font = new Font("Microsoft Sans Serif", 8, FontStyle.Regular);


            this.RefreshGrid();

            string sql = "SELECT tbl_DM_ChucNang.IdChucNang, tbl_DM_ChucNang.TenChucNang " +
                         "FROM tbl_DM_ChucNang;";
            GtidCommand SqlComm    = null;
            IDataReader DataReader = null;

            //Connection objConn = new Connection();
            //SqlConnection SqlConn = Connection.Instance.GetSqlConnection();
            //using (SqlConnection SqlConn = objConn.GetSqlConnection())
            //{
            try
            {
                //if (!(SqlConn.State == ConnectionState.Open)) SqlConn.Open();
                SqlComm             = ConnectionUtil.Instance.GetConnection().CreateCommand();
                SqlComm.CommandType = CommandType.Text;
                SqlComm.CommandText = sql;
                DataReader          = SqlComm.ExecuteReader();

                while (DataReader.Read())
                {
                    chklstRightOfGroup.Items.Add(new ListItem(Common.IntValue(DataReader[0].ToString()), DataReader[1].ToString()), false);
                }
                DataReader.Close();
            }

            catch
            {
            }
            finally
            {
                //if (!(SqlConn.State == ConnectionState.Closed)) SqlConn.Close();
            }
            this.dgvGroupList_SelectionChanged(null, EventArgs.Empty);
            //}

            this.SetButtomStatus(Declare.GroupCode);
        }
Exemplo n.º 3
0
        private void LoadThongTin()
        {
            //Connection objConn = new Connection();
            IDataReader DataReader = null;

            //SqlConnection SqlConn = Connection.Instance.GetSqlConnection();
            //using (SqlConnection SqlConn = objConn.GetSqlConnection())
            //{
            try
            {
                IDbCommand SqlComm = new GtidCommand("Select * From tbl_ThongTin", ConnectionUtil.Instance.GetConnection());
                SqlComm.CommandType = CommandType.Text;
                //if (!(SqlConn.State == ConnectionState.Open)) SqlConn.Open();
                DataReader = SqlComm.ExecuteReader();
                if (DataReader.Read())
                {
                    //while (DataReader.Read())
                    //{
                    txtTenDoanhNghiep.Text         = DataReader["TenDoanhNghiep"].ToString();
                    txtDiaChi.Text                 = DataReader["DiaChi"].ToString();
                    txtVPGiaoDich.Text             = DataReader["VPGiaoDich"].ToString();
                    txtDienThoai.Text              = DataReader["DienThoai"].ToString();
                    txtFax.Text                    = DataReader["Fax"].ToString();
                    txtEmail.Text                  = DataReader["Email"].ToString();
                    txtWebsite.Text                = DataReader["Website"].ToString();
                    txtMaSoThue.Text               = DataReader["MaSoThue"].ToString();
                    txtSoTaiKhoan.Text             = DataReader["SoTaiKhoan"].ToString();
                    txtNganHang.Text               = DataReader["NganHang"].ToString();
                    txtMota.Text                   = DataReader["MoTa"].ToString();
                    this.cboLoaiTien.SelectedValue = Common.IntValue(DataReader["IdTienTe"].ToString());
                    txtTyleGia.Text                = DataReader["TyLeGia"].ToString();
                    string str = DataReader["ChuanMaVach"].ToString();
                    if (str != "")
                    {
                        for (int i = 0; i < mavach.Length; i++)
                        {
                            if (mavach[i].Equals(str))
                            {
                                cboChuanMaVach.SelectedIndex = i;
                                break;
                            }
                        }
                    }
                    //}
                }
                else
                {
                    txtTenDoanhNghiep.Text      = "";
                    txtDiaChi.Text              = "";
                    txtVPGiaoDich.Text          = "";
                    txtDienThoai.Text           = "";
                    txtFax.Text                 = "";
                    txtEmail.Text               = "";
                    txtWebsite.Text             = "";
                    txtMaSoThue.Text            = "";
                    txtSoTaiKhoan.Text          = "";
                    txtNganHang.Text            = "";
                    txtMota.Text                = "";
                    txtTyleGia.Text             = "0";
                    cboChuanMaVach.SelectedText = "Code 128";
                }
            }
            catch
            {
            }
            finally
            {
                DataReader.Close();
                //if (!(SqlConn.State == ConnectionState.Closed)) SqlConn.Close();
            }
            //}
        }