private void InsertIntoDataTableAndDataGrid()
        {
            try
            {
                DataRow dr = null;
                Utility.AddColumToDataTable(ref mv_ParentTable, "Patient_ID", typeof(int));
                Utility.AddColumToDataTable(ref mv_ParentTable, "PID", typeof(string));
                Utility.AddColumToDataTable(ref mv_ParentTable, "Patient_Name", typeof(string));
                Utility.AddColumToDataTable(ref mv_ParentTable, "Age", typeof(int));
                Utility.AddColumToDataTable(ref mv_ParentTable, "Year_Birth", typeof(int));
                Utility.AddColumToDataTable(ref mv_ParentTable, "DOB", typeof(string));
                Utility.AddColumToDataTable(ref mv_ParentTable, "sexName", typeof(string));
                Utility.AddColumToDataTable(ref mv_ParentTable, "Sex", typeof(int));
                Utility.AddColumToDataTable(ref mv_ParentTable, "ObjectType", typeof(int));
                Utility.AddColumToDataTable(ref mv_ParentTable, "ObjectType_Name", typeof(string));
                Utility.AddColumToDataTable(ref mv_ParentTable, "Diagnostic", typeof(string));
                Utility.AddColumToDataTable(ref mv_ParentTable, "IdentifyNum", typeof(string));
                Utility.AddColumToDataTable(ref mv_ParentTable, "Insurance_Num", typeof(string));
                Utility.AddColumToDataTable(ref mv_ParentTable, "Address", typeof(string));
                Utility.AddColumToDataTable(ref mv_ParentTable, "Department_Name", typeof(string));
                Utility.AddColumToDataTable(ref mv_ParentTable, "DepartmentID", typeof(int));
                Utility.AddColumToDataTable(ref mv_ParentTable, "Room", typeof(string));
                Utility.AddColumToDataTable(ref mv_ParentTable, "DateUpdate", typeof(string));
                Utility.AddColumToDataTable(ref mv_ParentTable, "Bed", typeof(string));
                Utility.AddColumToDataTable(ref mv_ParentTable, "LotID", typeof(int));
                Utility.AddColumToDataTable(ref mv_ParentTable, "CanLamSang_ID", typeof(string));
                Utility.AddColumToDataTable(ref mv_ParentTable, "User_ID", typeof(string));


                dr = mv_ParentTable.NewRow();
                if (mv_ParentTable.Columns.Contains("Barcode"))
                {
                    dr["Barcode"] = "";
                }
                try
                {
                    dr["Patient_ID"]   = txtPatient_ID.Text;
                    dr["PID"]          = txtPID.Text;
                    dr["Patient_Name"] = txtPName.Text;

                    if (chkIsBirth.Checked)
                    {
                        dr["Age"]        = Convert.ToInt32(txtAge.Text);
                        dr["Year_Birth"] = Convert.ToInt32(txtYearOfBirth.Text);
                        if (chkDOB.Checked)
                        {
                            dr[LPatientInfo.Columns.Dob] = dtpDOB.Value.Date;
                        }
                        else
                        {
                            dr[LPatientInfo.Columns.Dob] = DBNull.Value;
                        }
                    }
                    else
                    {
                        dr["Age"]        = DBNull.Value;
                        dr["Year_Birth"] = DBNull.Value;
                    }
                    if (cboSex.SelectedValue == DBNull.Value)
                    {
                        dr["Sex"]     = DBNull.Value;
                        dr["sexName"] = "";
                    }
                    else
                    {
                        dr["Sex"]     = Convert.ToInt32(cboSex.SelectedValue);
                        dr["sexName"] = cboSex.Text;
                    }

                    dr["ObjectType"]      = Utility.Int32Dbnull(cboObject.SelectedValue, -1);
                    dr["ObjectType_Name"] = Utility.sDbnull(cboObject.Text, "");
                    dr["Diagnostic"]      = txtDiagnostic.Text;
                    dr["IdentifyNum"]     = txtCMT.Text;
                    dr["Insurance_Num"]   = Utility.sDbnull(txtInsuranceNum.Text);
                    dr["Address"]         = txtAddress.Text;
                    dr["Department_Name"] = (Utility.Int32Dbnull(cboDepartment.SelectedValue) < 1 ? "" : cboDepartment.Text);
                    int departmentId = Utility.Int32Dbnull(cboDepartment.SelectedValue, -1);
                    dr["DepartmentID"]  = departmentId;
                    dr["Room"]          = txtRoom.Text.Trim();
                    dr["Bed"]           = txtBed.Text.Trim();
                    dr["DateUpdate"]    = dtmDate.Text;
                    dr["LotID"]         = Utility.Int32Dbnull(cboLot.SelectedValue, -1);
                    dr["CanLamSang_ID"] = txtCanLamSangID.Text;
                    dr["User_ID"]       = Utility.sDbnull(globalVariables.UserName);
                }
                catch (Exception ex)
                {
                    Utility.ShowMsg(ex.Message);
                }


                //  PatientInfo2Datarow(ref dr);
                mv_ParentTable.Rows.InsertAt(dr, 0);
                grdList.MoveFirst();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
 protected void MoveFirst()
 {
     grdData.MoveFirst();
 }