Пример #1
0
        private async void Update_Load(object sender, EventArgs e)
        {
            #region Setup comboBox value for Status

            var dt = new DataTable();
            dt.Columns.Add("Text", typeof(string));
            dt.Columns.Add("Val", typeof(byte));

            var rNoVal = dt.NewRow();
            rNoVal["Text"] = "Select";
            dt.Rows.Add(rNoVal);

            var row = dt.NewRow();
            row["Text"] = Status.Active.ToString();
            row["Val"]  = (byte)Status.Active;
            dt.Rows.Add(row);

            var row2 = dt.NewRow();
            row2["Text"] = Status.Dropped.ToString();
            row2["Val"]  = (byte)Status.Dropped;
            dt.Rows.Add(row2);

            cmbStatus.DataSource    = dt;
            cmbStatus.DisplayMember = "Text";
            cmbStatus.ValueMember   = "Val";

            #endregion

            #region   Get Student Details

            var query = "select top 1 GStudentId, Name,Birthdate,Gender,Address,School,cast(Status as int) as Status,Recorded " +
                        "FROM Student " +
                        "where GStudentId=@GStudentId";
            var result = await DBase.GetById <Student>(query, new { GStudentId = _studentId });

            txtName.Text            = result.Name;
            drpDOB.Value            = result.Birthdate;
            rdbFemale.Checked       = result.Gender == "F"; rdbMale.Checked = result.Gender == "M";
            cmbStatus.SelectedValue = result.Status;
            txtAddress.Text         = result.Address;
            txtSchool.Text          = result.School;

            #endregion
        }