public Advertisement(OleDbDataReader reader)
 {
     this.StrId = reader.GetString(0);
     if (!reader.IsDBNull(1))
         this.IntType = reader.GetInt32(1);
     else
         this.IntType = 3;
     if (!reader.IsDBNull(2))
         this.StrContent = reader.GetString(2);
     else
         this.StrContent = "";
 }
 public Coupon(OleDbDataReader reader)
 {
     this.StrId = reader.GetString(0);
     if (!reader.IsDBNull(1))
         this.StrSmallImg = reader.GetString(1);
     else
         this.strSmallImg = "";
     if (!reader.IsDBNull(2))
         this.StrLargeImg = reader.GetString(2);
     else
         this.StrLargeImg = "";
     if (!reader.IsDBNull(3))
         this.StrPrintImg = reader.GetString(3);
     else
         this.StrPrintImg = "";
 }
Exemple #3
0
        public Form1()
        {
            InitializeComponent();
            PC.list = new List<PC>();
            PC.total = new List<PC>();
            data.Columns.Add("Id", "Id");
            data.Columns.Add("PC", "PC");
            data.Columns.Add("Inicio", "Inicio");
            data.Columns.Add("Tiempo", "Tiempo");
            data.Columns.Add("Total", "Total");
            data.Columns[3].Width = 130;
            data.Columns[3].Width = 130;
            r = MSAConnection.read("select * from item");
            while (r.Read())
            {
                String d = "";
                PC p = new PC();
                p.id = r.GetInt32(0);
                p.precio = r.GetInt32(2);
                if (!r.IsDBNull(3))
                {
                    //d = r.GetDateTime(3).ToString();
                    DateTime x = r.GetDateTime(3);
                    d = x.Hour + ":" + x.Minute + ":" + x.Second;
                    p.inicio = r.GetDateTime(3);
                    PC.list.Add(p);
                }
                PC.total.Add(p);
                data.Rows.Add(r.GetInt32(0), r.GetString(1), d);
            }
            //            MessageBox.Show(PC.total.Count + "");

            thetimer.Start();
        }
        private void SaveColumnValues(OleDb.OleDbConnection conn, List <string> indexNames, ref Dictionary <string, int> dictionary)
        {
            //Call ReadColumnNames first!
            int indexNumber = 0;

            //just making sure column names are populated
            if (indexNames.Count() == 0)
            {
                return;
            }

            foreach (string index in indexNames)
            {
                //no need to prepare this command
                OleDb.OleDbCommand selectAll = new OleDb.OleDbCommand("SELECT `" + index + "` FROM `Sheet1$`", conn);
                try {
                    OleDb.OleDbDataReader reader = selectAll.ExecuteReader();
                    while (reader.Read())
                    {
                        //potentially throws invalid cast exception (null)
                        if (!reader.IsDBNull(0))
                        {
                            string word = reader.GetString(0);
                            //clean word
                            string cleanWord = Globals.ThisAddIn.HighlightManager.CleanWord(word);
                            //save word
                            if (Globals.ThisAddIn.HighlightManager.CanAddToDictionary(cleanWord))
                            {
                                dictionary.Add(cleanWord, indexNumber);
                            }
                        }
                    }
                    reader.Close();
                } catch (OleDb.OleDbException)
                {
                    Forms.MessageBox.Show(Strings.error, Strings.errorCaption);
                }
                indexNumber++;
            }
        }
        private PivotFacetCategory CreateFacetCategory(OleDbDataReader dataReader)
        {
            String name = null;
            PivotFacetType type = null;

            for (int column = 0; column < dataReader.FieldCount; column++)
            {
                if (dataReader.IsDBNull(column)) continue;

                String columnName = dataReader.GetName(column).ToLowerInvariant();
                String value = dataReader.GetValue(column).ToString();

                if (columnName == OleDbSchemaConstants.FacetCategory.Name)
                {
                    name = value;
                }
                else if (columnName == OleDbSchemaConstants.FacetCategory.Type)
                {
                    type = PivotFacetType.Parse(value);
                }
            }
            if (name == null) throw new InvalidDataException("Facet Categories data set is missing a Name column");
            if (type == null) throw new InvalidDataException("Facet Categories data set is missing a Type column");
            return new PivotFacetCategory(name, type);
        }
        // Display the result set recursively expanding chapterDepth deep
        public void DisplayReader(OleDbDataReader myDataReader, ref uint count, uint alignment, int chapterDepth)
        {
            try
            {
                // compute alignment
                StringBuilder indent = new StringBuilder((int) alignment);
                indent.Append(' ', (int) alignment);

                while (myDataReader.Read())
                {
                    // add alignment
                    StringBuilder row = new StringBuilder(indent.ToString());

                    // for all columns
                    for (int i = 0; i < myDataReader.FieldCount; i++)
                    {
                        // null columns
                        if (myDataReader.IsDBNull(i))
                        {
                            row.Append("NULL;");
                        }
                        else
                        {

                            //vector columns
                            object[] myArray = myDataReader.GetValue(i) as object[];
                            if (myArray != null)
                            {
                                DisplayValue(myArray, row);
                            }
                            else
                            {
                                //check for chapter columns from "group on" queries
                                if (myDataReader.GetFieldType(i).ToString() != "System.Data.IDataReader")
                                {
                                    //regular columns are displayed here
                                    row.Append(myDataReader.GetValue(i));
                                }
                                else
                                {
                                    //for a chapter column type just display the colum name
                                    row.Append(myDataReader.GetName(i));
                                }
                            }
                            row.Append(';');
                        }
                    }
                    if (chapterDepth >= 0)
                    {
                        this.ScrubberGUIInst.DebugPrint(row.ToString());
                        count++;
                    }
                    // for each chapter column
                    for (int i = 0; i < myDataReader.FieldCount; i++)
                    {
                        if (myDataReader.GetFieldType(i).ToString() == "System.Data.IDataReader")
                        {
                            OleDbDataReader Reader = myDataReader.GetValue(i) as OleDbDataReader;
                            DisplayReader(Reader, ref count, alignment + 8, chapterDepth - 1);
                        }
                    }
                }
            }
            finally
            {
                myDataReader.Close();
                myDataReader.Dispose();
            }
        }
        public Element(OleDbDataReader reader)
        {
            this._strName = reader.GetString(1);

            if (!reader.IsDBNull(2))
                this._strLocation = reader.GetString(2);
            else
                this._strLocation = "";

            if (!reader.IsDBNull(3))
                this._strSize = reader.GetString(3);
            else
                this._strSize = "";

            if (!reader.IsDBNull(4))
                this._strBgImage = reader.GetString(4);
            else
                this._strBgImage = "";

            if (!reader.IsDBNull(5))
                this._strFontFamily = reader.GetString(5);
            else
                this._strFontFamily = "";

            if (!reader.IsDBNull(6))
                this._strContent = reader.GetString(6);
            else
                this._strContent = "";

            if (!reader.IsDBNull(7))
                this._intFontSize = reader.GetInt16(7);
            else
                this._intFontSize = 0;

            if (!reader.IsDBNull(8))
                this._strFontColor = reader.GetString(8);
            else
                this._strFontColor = "";

            if (!reader.IsDBNull(9))
                this._strCtlName = reader.GetString(9);
            else
                this._strCtlName = "";
        }
 public Shop(OleDbDataReader reader)
 {
     this.StrId = reader.GetString(0);
     if (!reader.IsDBNull(1))
         this.StrSmallImg = reader.GetString(1);
     else
         this.StrSmallImg = "";
     if (!reader.IsDBNull(2))
         this.StrLargeImg = reader.GetString(2);
     else
         this.StrLargeImg = "";
 }
 public void LoadPatient(string patientID)
 {
     string strSQL;OleDbCommand myCom;
     OleDbDataReader myReader;
     int i, n, c;
     this.isEditPatient =true;
     strSQL = "SELECT Patient_Name, Patient_Address, Patient_Age, Patient_Gender, Patient_Tel, Patient_Career FROM tblPatient WHERE Patient_ID=" + patientID + ";";
     myCom = refConn.CreateCommand();
     myCom.CommandText = strSQL;
     myReader = myCom.ExecuteReader();
     if (myReader.HasRows)
     {
         myReader.Read();
         strPatientID = patientID;
         txtPatientName.Text = myReader.GetString(0);
         txtPatientAddress.Text = myReader.IsDBNull(1)?"":myReader.GetString(1);
         txtPatientAge.Text = myReader.GetByte(2).ToString();
         cboPatientGender.SelectedIndex = myReader.GetByte(3);
         txtPatientPhone.Text = myReader.IsDBNull(4)?"":myReader.GetString(4);
         if (!myReader.IsDBNull(5))
         {
             n = lstCareerID.Items.Count-1;
             c = myReader.GetInt32(5);
             for(i=0; i<n; i++)
             {
                 if (int.Parse(lstCareerID.Items[i].ToString())==c)
                 {
                     cboPatientCareer.SelectedIndex =i;
                     break;
                 }
             }
         }else cboPatientCareer.SelectedIndex =-1;
         strPatientID = patientID;
     }
 }
Exemple #10
0
  public void AddFromReader(OleDbDataReader reader, bool addSpace)
  {
    do
    {
      if (reader.HasRows)
      {
        HtmlGenericControl resultSetDiv = CreateDiv("ResultSet");
        _container.Controls.Add(resultSetDiv);

        int headerColumn = reader.GetColumnIndex("Header");
        string lastHeader = null;
        
        int subheaderColumn = reader.GetColumnIndex("Subheader");
        string lastSubHeader = null;
        
        int lastColumn = reader.FieldCount - 1;

        for (int i = 0; i < 2; ++i)
        {
          if (lastColumn == headerColumn || lastColumn == subheaderColumn)
          {
            lastColumn -= 1;
          }
        }

        while (reader.Read())
        {
          HtmlGenericControl rowSetDiv = CreateDiv("RowSet");
          resultSetDiv.Controls.Add(rowSetDiv);

          bool headerAdded = false;
          bool subheaderAdded = false;

          if (headerColumn >= 0 && !reader.IsDBNull(headerColumn))
          {
            string header = reader.GetValue(headerColumn).ToString();
            headerAdded = header != lastHeader;

            if (headerAdded)
            {
              HtmlGenericControl headerDiv = CreateDiv("RowSetHeader", header);
              rowSetDiv.Controls.Add(headerDiv);
              lastHeader = header;
            }
          }

          if (subheaderColumn >= 0 && !reader.IsDBNull(subheaderColumn))
          {
            string subheader = reader.GetValue(subheaderColumn).ToString();
            subheaderAdded = subheader != lastSubHeader;

            if (subheaderAdded)
            {
              if (headerAdded && addSpace)
              {
                AddSpace(rowSetDiv, "Space2");
              }

              HtmlGenericControl subheaderDiv = CreateDiv("RowSetSubheader", subheader);
              rowSetDiv.Controls.Add(subheaderDiv);
              lastSubHeader = subheader;
            }
          }

          if (lastColumn < 0)
          {
            if (addSpace)
            {
              AddSpace(rowSetDiv, "Space2");
            }
          }
          else
          {
            if ((headerAdded || subheaderAdded) && addSpace)
            {
              AddSpace(rowSetDiv, "Space2");
            }

            for (int i = 0; i < reader.FieldCount; ++i)
            {
              if (i != headerColumn && i != subheaderColumn)
              {
                HtmlGenericControl valueSetDiv = CreateDiv("ValueSet");
                rowSetDiv.Controls.Add(valueSetDiv);

                HtmlGenericControl labelDiv = CreateDiv("Label", reader.GetName(i));
                valueSetDiv.Controls.Add(labelDiv);

                if (addSpace)
                {
                  HtmlGenericControl separatorDiv = CreateDiv("Separator", "");
                  valueSetDiv.Controls.Add(separatorDiv);
                }

                HtmlGenericControl valueDiv = CreateValueDiv(!reader.IsDBNull(i) ? reader.GetValue(i) : null);
                valueSetDiv.Controls.Add(valueDiv);

                if (i < lastColumn && addSpace)
                {
                  AddSpace(rowSetDiv, "Space1");
                }
              }
            }

            if (addSpace)
            {
              AddSpace(rowSetDiv, "Space4");
            }
          }
        }
      }
    }
    while (reader.NextResult());
  }
 void GenerateRecordID()
 {
     string strSQL;
     OleDbDataReader myReader;
     OleDbCommand myCom;
     strSQL = "SELECT MAX(tblProfile.PROFILE_ID) FROM tblProfile;";
     myCom = this.refConn.CreateCommand();
     myCom.CommandText = strSQL;
     myReader = myCom.ExecuteReader();
     if (myReader.HasRows)
     {
         while (myReader.Read())
         {
             if ( myReader.IsDBNull(0) )
                 txtRecordID.Text = "1";
             else
                 txtRecordID.Text= (myReader.GetInt32(0)+1).ToString();
         }
     }else txtRecordID.Text = "1";
     myReader.Close();
 }
        public void setReferenceConnectNLoadData(ref OleDbConnection refParent, ref MemoryStream ReportDefinition, ref Image imgHeader, string ReportTitle)
        {
            string strSQL;
            int pType, cType;
            int YPoint, i;
            Button btnRefTmp;
            ComboBox cboShow_Diag = new ComboBox();
            cboShow_Treatment = new ComboBox();
            Label lblShow_Diag;

            OleDbCommand myCom = new OleDbCommand();
            OleDbDataReader myReader;
            pType = -1;
            this.refConn = refParent;
            this.refImageHeader = CopyImage(imgHeader);
            this.ReportTitle = ReportTitle;
            strSQL = "SELECT tblMasterInfor.M_ID, tblMasterInfor.M_Type, tblMasterInfor.M_Name, tblDetailsInfor.Details_ID, tblDetailsInfor.Details_Content FROM tblMasterInfor LEFT JOIN tblDetailsInfor ON tblMasterInfor.M_ID = tblDetailsInfor.Mas_ID WHERE tblMasterInfor.M_Type=" + frmAddNewMasterItem.ENUM_INTEGER_CATOGERY_DIAGNOSIS.ToString() + ";";
            myCom.CommandText = strSQL;
            myCom.Connection = refParent;
            myReader = myCom.ExecuteReader();
            YPoint = 453;nDiagType=0;
            lstComboName.Items.Clear();
            txtExtraDiagnosis = new TextBox();
            cboExtraNote = new ComboBox();

            txtExtraTreatment = new TextBox();
            if (myReader.HasRows)
            {
                while (myReader.Read())
                {
                    cType  = myReader.GetInt32(0);
                    if (cType!=pType)
                    {//new combo
                        cboShow_Diag = new ComboBox();
                        cboShow_Diag.Cursor = Cursors.Hand;
                        cboShow_Diag.FlatStyle = FlatStyle.Popup;
                        cboShow_Diag.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                        cboShow_Diag.FormattingEnabled = true;
                        cboShow_Diag.Name = cType.ToString();
                        cboShow_Diag.Location = new System.Drawing.Point(180, YPoint);
                        lstComboName.Items.Add(COMBO_DIAGNOSIS_NAME + myReader.GetInt32(0).ToString());
                        cboShow_Diag.Name = COMBO_DIAGNOSIS_NAME + myReader.GetInt32(0).ToString();
                        cboShow_Diag.Size = new System.Drawing.Size(430, 28);

                        lblShow_Diag = new Label();
                        lblShow_Diag.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                        lblShow_Diag.Location = new System.Drawing.Point(99, YPoint);
                        lblShow_Diag.Name = "lbl"+COMBO_DIAGNOSIS_NAME + nDiagType.ToString();
                        lblShow_Diag.Size = new System.Drawing.Size(100, 23);
                        lblShow_Diag.Text = myReader.GetString(2);
                        pType = cType;
                        YPoint += 30;
                        nDiagType++;
                        this.Controls.Add(cboShow_Diag);
                        this.Controls.Add(lblShow_Diag);
                    }//new item
                    if (cboShow_Diag!=null)
                    {
                        //tblDetailsInfor.Details_ID, tblDetailsInfor.Details_Content
                        if (!myReader.IsDBNull(3))
                        {
                            cboShow_Diag.Items.Add(myReader.GetValue(3).ToString() + FRM_SEPPERATE_ID_NAME + myReader.GetValue(4).ToString());
                        }
                    }
                }//read one record
            }//has rows
            txtExtraDiagnosis.Location= new System.Drawing.Point(180, YPoint);
            txtExtraDiagnosis.Size = new System.Drawing.Size(430, 46);
            txtExtraDiagnosis.Multiline =true;
            //txtExtraDiagnosis.BorderStyle
            YPoint += 52;
            this.cboShow_Diagnosis = new ComboBox[nDiagType];
            for (i=0; i<nDiagType; i++)
            {
                this.cboShow_Diagnosis[i] = (ComboBox)this.Controls[lstComboName.Items[i].ToString()];
            }
            myReader.Close();
            strSQL = "SELECT tblMasterInfor.M_ID, tblMasterInfor.M_Type, tblMasterInfor.M_Name, tblDetailsInfor.Details_ID, tblDetailsInfor.Details_Content FROM tblMasterInfor LEFT JOIN tblDetailsInfor ON tblMasterInfor.M_ID = tblDetailsInfor.Mas_ID WHERE tblMasterInfor.M_Type=" + frmAddNewMasterItem.ENUM_INTEGER_CATOGERY_TREATMENT.ToString() + ";";
            myCom.CommandText = strSQL;
            myCom.Connection = refParent;
            myReader = myCom.ExecuteReader();
            lblLastTreatment.Location= new System.Drawing.Point(1, YPoint);

            cboShow_Treatment = new ComboBox();
            cboShow_Treatment.Cursor = Cursors.Hand;
            cboShow_Treatment.FlatStyle = FlatStyle.Popup;
            cboShow_Treatment.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            cboShow_Treatment.FormattingEnabled = true;
            cboShow_Treatment.Location = new System.Drawing.Point(180, YPoint);
            cboShow_Treatment.Name = "cboShow_Treatment";
            cboShow_Treatment.Size = new System.Drawing.Size(430, 28);
            nDiagType ++;
            this.Controls.Add(cboShow_Treatment);

            cboShow_Treatment.Items.Clear();

            if (myReader.HasRows)
            {
                while (myReader.Read())
                {
                    if (!myReader.IsDBNull(3))
                    {
                        cboShow_Treatment.Items.Add(myReader.GetValue(3).ToString() + FRM_SEPPERATE_ID_NAME + myReader.GetValue(4).ToString());
                    }
                }
            }
            myReader.Close();
            YPoint += 30;
            txtExtraTreatment.Size = new System.Drawing.Size(430, 46);
            txtExtraTreatment.Location= new System.Drawing.Point(180, YPoint);
            txtExtraTreatment.Multiline = true;
            YPoint+=48;
            strSQL = "SELECT tblMasterInfor.M_ID, tblMasterInfor.M_Type, tblMasterInfor.M_Name, tblDetailsInfor.Details_ID, tblDetailsInfor.Details_Content FROM tblMasterInfor LEFT JOIN tblDetailsInfor ON tblMasterInfor.M_ID = tblDetailsInfor.Mas_ID WHERE tblMasterInfor.M_Type=" + frmAddNewMasterItem.ENUM_INTEGER_CATOGERY_CAREER.ToString() + ";";
            myCom.CommandText = strSQL;
            myReader = myCom.ExecuteReader();
            cboPatientCareer.Items.Clear();
            lstCareerID.Items.Clear();
            lblDoctorNote.Location = new System.Drawing.Point(1, YPoint);
            cboExtraNote.Size = new System.Drawing.Size(430, 46);
            cboExtraNote.Location= new System.Drawing.Point(180, YPoint);
            //txtPatientName.Text = strSQL;

            if (myReader.HasRows)
            {
                while (myReader.Read())
                {
                    if (!myReader.IsDBNull(3))
                    {
                        cboPatientCareer.Items.Add(myReader.GetValue(4).ToString());
                        lstCareerID.Items.Add(myReader.GetValue(3).ToString());
                    }
                }
            }
            myReader.Close();
            GenerateRecordID();

            myCom.CommandText = "SELECT Details_ID, Details_Content FROM tblDetailsInfor WHERE Mas_ID=13;" ;
            myReader = myCom.ExecuteReader();
            if (myReader.HasRows)
            {
                while (myReader.Read())
                {
                    lstDrID.Add(myReader.GetInt32(0));
                    cboDrName.Items.Add (myReader.GetString(1));
                }
            };
            myReader.Close();
            for (i=1; i<5; i++)
            {
                btnRefTmp = (Button)this.Controls["btn_pic_Frame" + i.ToString()];
                btnRefTmp.Click += new EventHandler(btnBrowse4Image_Click);
            }

            myCom.CommandText = "SELECT Details_ID, Details_Content FROM tblDetailsInfor WHERE Mas_ID=15;";
            myReader = myCom.ExecuteReader();
            cboExtraNote.Items.Clear();
            if (myReader.HasRows)
            {
                while (myReader.Read())
                {
                    cboExtraNote.Items.Add(myReader.GetString(1));
                }
            };
            myReader.Close();

            this.Controls.Add(txtExtraDiagnosis);
            this.Controls.Add(txtExtraTreatment);
            this.Controls.Add(cboExtraNote);
            this.ReportDefinition = ReportDefinition;
            this.Height = this.cboExtraNote.Top+this.cboExtraNote.Height + 40;
        }
        public void LoadProfile(string ProfileID)
        {
            OleDbCommand myCom;
            OleDbDataReader myReader;
            string[] strOther;
            string strTmp, strOneItem;
            int i, intCombo, n, noOfComboBox, noOfImages, x;
            bool isContinue;
            myCom = refConn.CreateCommand();
            myCom.CommandText ="SELECT Pro_PatientID, Pro_Date, Pro_Image1, Pro_Image2, Pro_Image3, Pro_Image4, Pro_Image5, Pro_Image6, Pro_Comment1, Pro_Comment2, Pro_Comment3, Pro_Comment4, Pro_Comment5, Pro_Comment6, Pro_Other, Pro_ExtraDiagnosis, Pro_ExtraTreatment, Pro_DoctorNote FROM tblProfile WHERE PROFILE_ID=" + ProfileID + ";";
            myReader = myCom.ExecuteReader();
            if (myReader.HasRows)
            {
                myReader.Read();
                LoadPatient(myReader.GetInt32(0).ToString());
                noOfImages = 0;
                for (i=2; i<8; i++)
                {
                    if (!myReader.IsDBNull(i))
                    {
                        noOfImages ++;
                        LoadImage(myReader.GetString(i), i-1);
                    }
                }
                nudNoOfPicture.Value = noOfImages;
                NudNoOfPictureValueChanged(null, null);
                for (i=8;i<14 ;i++ ) if (!myReader.IsDBNull(i)) ((TextBox)this.Controls["txtNote_" + (i-5).ToString()]).Text = myReader.GetString(i);
                noOfComboBox = cboShow_Diagnosis.Length;
                if (!myReader.IsDBNull(14))
                {
                    string [] strXXX;
                    strXXX = new string[]{OTHER_DIAGNOSIS_SEPERATE};
                    strTmp = myReader.GetValue(14).ToString();
                    strOther = strTmp.Split(strXXX, StringSplitOptions.RemoveEmptyEntries);
                    n = strOther.Length;
                    for (i=0; i<n; i++)
                    {

                        for (intCombo =0; intCombo<noOfComboBox; intCombo++)
                        {
                            strTmp = cboShow_Diagnosis[intCombo].Name.Substring(COMBO_DIAGNOSIS_NAME.Length);
                            if (strOther[i].StartsWith(strTmp))
                            {
                                x = strOther[i].IndexOf(FRM_SEPPERATE_ID_NAME) + FRM_SEPPERATE_ID_NAME.Length;
                                cboShow_Diagnosis[intCombo].Text = strOther[i].Substring(x);
                            }

                        }//Visit all diag
                        strTmp = cboShow_Treatment.Name.Substring(COMBO_DIAGNOSIS_NAME.Length);
                        if (strOther[i].StartsWith(strTmp))
                        {
                            x = strOther[i].IndexOf(FRM_SEPPERATE_ID_NAME) + FRM_SEPPERATE_ID_NAME.Length;
                            cboShow_Treatment.Text = strOther[i].Substring(x);
                        }
                    //Get treatment
                    }
                }//Composite field
                //Extra diagnosis
                if (!myReader.IsDBNull(15))
                    txtExtraDiagnosis.Text = myReader.GetString(15);
                else
                    txtExtraDiagnosis.Text= "";
                if (!myReader.IsDBNull(16))
                    txtExtraTreatment.Text = myReader.GetString(16);
                else
                    txtExtraTreatment.Text= "";
                if (!myReader.IsDBNull(17))
                    cboExtraNote.Text = myReader.GetString(17);
                else
                    cboExtraNote.Text= "";
            }else
            {
                return;
            }
            myReader.Close();
            myCom.CommandText = "SELECT Profile_Related FROM tblProfileDetails WHERE Profile_ID =" + ProfileID + ";";
            myReader = myCom.ExecuteReader();
            noOfComboBox = cboShow_Diagnosis.Length;
            if (myReader.HasRows)
            {
                while (myReader.Read())
                {
                    strTmp = myReader.GetInt32(0).ToString() + FRM_SEPPERATE_ID_NAME;
                    isContinue = true;
                    for (intCombo =0; intCombo<noOfComboBox; intCombo++)
                    {
                        n = cboShow_Diagnosis[intCombo].Items.Count;
                        for (i=0; i<n; i++)
                        {
                            strOneItem = cboShow_Diagnosis[intCombo].Items[i].ToString();
                            if (strOneItem.StartsWith(strTmp))
                            {
                                cboShow_Diagnosis[intCombo].SelectedIndex = i;
                                intCombo = noOfComboBox;
                                isContinue =false;
                                i=n;
                            }
                        }
                    }//Visit all diag
                    //Get treatment
                    if (isContinue)
                    {
                        n = cboShow_Treatment.Items.Count;
                        for (i=0; i<n; i++)
                        {
                            strOneItem = cboShow_Treatment.Items[i].ToString();
                            if (strOneItem.StartsWith(strTmp))
                            {
                                cboShow_Treatment.SelectedIndex = i;
                                i=n;
                                isContinue =false;
                            }
                        }
                    }//end if
                    if (isContinue)
                    {
                        n = lstDrID.Count;
                        for (i=0; i<n; i++)
                        {
                            if (lstDrID[i]==myReader.GetInt32(0))
                            {
                                cboDrName.SelectedIndex = i;
                                i=n;
                                //isContinue =false;
                            }
                        }
                    }
                }
            }//HasRows
            txtRecordID.Text = ProfileID;
            myReader.Close();
            myCom.Dispose();
            tsbtnSave.Enabled =false;
            lblCapture.Enabled=false;
            tsbtnPrint.Enabled =true;
            tsbtnPreview.Enabled=true;
            this.btsDeleteProfile.Enabled =true;
            LockPatientInformation(true);
        }
        private PivotItem ReadItem(OleDbDataReader dataReader, int rowId)
        {
            PivotItem item = new PivotItem(rowId.ToString(), this);

            for (int column = 0; column < dataReader.FieldCount; column++)
            {
                if (dataReader.IsDBNull(column)) continue;

                String columnName = dataReader.GetName(column).ToLowerInvariant();
                String value = dataReader.GetValue(column).ToString();
                if (String.IsNullOrEmpty(value)) continue;

                if (columnName == OleDbSchemaConstants.Item.Name)
                {
                    item.Name = value;
                }
                else if (columnName == OleDbSchemaConstants.Item.Image)
                {
                    String imagePath = UriUtility.ExpandRelativeUri(this.BasePath, value);
                    item.Image = new PivotImage(imagePath);
                }
                else if (columnName == OleDbSchemaConstants.Item.Description)
                {
                    item.Description = value;
                }
                else if (columnName == OleDbSchemaConstants.Item.Href)
                {
                    item.Href = value;
                }
                else if (columnName == OleDbSchemaConstants.Item.RelatedLinks)
                {
                    StringReader valueReader = new StringReader(value);
                    String singleValue = null;
                    while ((singleValue = valueReader.ReadLine()) != null)
                    {
                        String[] parts = singleValue.Split(
                            new String[] { OleDbSchemaConstants.LinkPartDelimiter }, StringSplitOptions.None);
                        if (parts.Length > 0)
                        {
                            String name = null, url = null;
                            if (parts.Length == 1)
                            {
                                url = parts[0];
                            }
                            else if (parts.Length >= 2)
                            {
                                name = parts[0];
                                url = parts[1];
                            }
                            item.AddRelatedLink(new PivotLink(name, url));
                        }
                    }
                }
                else
                {
                    PivotFacetCategory facetCategory = null;
                    foreach (PivotFacetCategory currentFacetCategory in m_facetCategoryMap.Values)
                    {
                        if (columnName == currentFacetCategory.Name.Replace('.', '#').ToLowerInvariant())
                        {
                            facetCategory = currentFacetCategory;
                            break;
                        }
                    }

                    if (facetCategory != null)
                    {
                        item.AddFacetValues(facetCategory.Name, this.SplitJoinedStrings(value).ToArray());
                    }
                }
            }

            return item;
        }
Exemple #15
0
        // Display the result set recursively expanding chapterDepth deep
        static void DisplayReader(OleDbDataReader myDataReader, ref uint count, uint alignment, int chapterDepth)
        {
            try
            {
                // compute alignment
                StringBuilder indent = new StringBuilder((int)alignment);
                indent.Append(' ', (int)alignment);

                while (myDataReader.Read())
                {
                    // add alignment
                    StringBuilder row = new StringBuilder(indent.ToString());

                    // for all columns
                    for (int i = 0; i < myDataReader.FieldCount; i++)
                    {
                        // null columns
                        if (myDataReader.IsDBNull(i))
                        {
                            row.Append("NULL\t");
                        }
                        else
                        {
                            //vector columns
                            object[] myArray = myDataReader.GetValue(i) as object[];
                            if (myArray != null)
                            {
                                DisplayValue(myArray, row);
                            }
                            else
                            {
                                //check for chapter columns from "group on" queries
                                if (myDataReader.GetFieldType(i).ToString() != "System.Data.IDataReader")
                                {
                                    //regular columns are displayed here
                                    //If (OptPath == false) and colName is System.ItemPathDisplay
                                    //We want to skip Display of this Column
                                    if (!(OptPath == false && myDataReader.GetName(i) == "System.ItemPathDisplay"))
                                        row.Append(myDataReader.GetValue(i));
                                }
                                else
                                {
                                    //for a chapter column type just display the colum name
                                    row.Append(myDataReader.GetName(i));
                                }
                            }
                            row.Append('\t');
                        }
                    }
                    if (chapterDepth >= 0)
                    {
                        Console.WriteLine(row.ToString());
                        count++;
                    }
                    // for each chapter column
                    for (int i = 0; i < myDataReader.FieldCount; i++)
                    {
                        if (myDataReader.GetFieldType(i).ToString() == "System.Data.IDataReader")
                        {
                            OleDbDataReader Reader = myDataReader.GetValue(i) as OleDbDataReader;
                            DisplayReader(Reader, ref count, alignment + 8, chapterDepth - 1);
                        }
                    }
                }
            }
            finally
            {
                myDataReader.Close();
                myDataReader.Dispose();
            }
        }
        /////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////
        private string GetNullableString(OleDbDataReader reader, int col)
        {
            if (reader.IsDBNull(col) == false)
            {
                return reader.GetString(col);
            }

            return null;
        }
        int InsertPatient(OleDbCommand myComm)
        {
            string strSQL;
            int intLastID;

            strSQL = "SELECT MAX(Patient_ID) FROM tblPatient";
            myComm.CommandText = strSQL;
            myReader = myComm.ExecuteReader();
            if (myReader.HasRows)
            {
                myReader.Read();
                if ( myReader.IsDBNull(0) )
                    intLastID=1;
                else
                    intLastID = myReader.GetInt32(0)+1;

            }else intLastID = 1;
            myReader.Close();

            strSQL = "INSERT INTO tblPatient (Patient_ID, Patient_Name, Patient_Address, Patient_Age, Patient_Gender, Patient_Tel, Patient_Career) VALUES(" + intLastID.ToString() +", '" + txtPatientName.Text + "', ";
            if (txtPatientAddress.Text.Length<=0)
            {
                strSQL += "NULL, " + txtPatientAge.Text + ", ";
            }
            else
            {
                strSQL += "'" + txtPatientAddress.Text + "', " + txtPatientAge.Text +", ";
            }
            strSQL += cboPatientGender.SelectedIndex.ToString() + ", ";
            if (txtPatientPhone.Text.Length<0)
            {
                strSQL += "NULL, ";
            }
            else
            {
                strSQL += "'" + txtPatientPhone.Text  + "', ";
            }
            if (cboPatientCareer.SelectedIndex<0)
            {
                strSQL += "NULL);";
            }
            else
            {
                strSQL += lstCareerID.Items[cboPatientCareer.SelectedIndex].ToString()  + ");";
            }
            myComm.CommandText = strSQL;
            //cboShow_Treatment.Text = strSQL;
            myComm.Connection = refConn;
            try{
                myComm.ExecuteNonQuery();
            }catch (Exception e)
            {
                MessageBox.Show (e.Message.ToString());
                return -1;
            }
            return intLastID;
        }