private void InitializeDGVs(int id)
        {
            //if (connectionType == ConnectionTypes.Connected)
            //{

            //}
            DGVDiagnoses.DataSource   = null;
            DGVMedications.DataSource = null;
            diagnosesId.Clear();
            medicationsId.Clear();

            string query = Commands.SelectPrescriptionsDiagnosesWhereId(id);

            ConnectedData.SetCommand(query);
            int[] size = new int[2];
            size = ConnectedData.GetRowAndColumnCount();
            int row    = size[0];
            int column = size[1];

            dataDiagnoses = new string[row, column];
            dataDiagnoses = ConnectedData.GetTableData();

            DGVDiagnoses.RowCount = row + 1;

            for (int i = 0; i < row; i++)
            {
                diagnosesId.Add(Convert.ToInt32(dataDiagnoses[i, 1]));
                DGVDiagnoses[0, i].Value = Convert.ToInt32(dataDiagnoses[i, 1]);
            }

            query = Commands.SelectPrescriptionsMedicationsWhereId(id);
            ConnectedData.SetCommand(query);
            size   = new int[2];
            size   = ConnectedData.GetRowAndColumnCount();
            row    = size[0];
            column = size[1];

            dataMedications = new string[row, column];
            dataMedications = ConnectedData.GetTableData();

            DGVMedications.RowCount = row + 1;

            for (int i = 0; i < row; i++)
            {
                medicationsId.Add(Convert.ToInt32(dataMedications[i, 1]), Convert.ToInt32(dataMedications[i, 2]));
                DGVMedications[0, i].Value = Convert.ToInt32(dataMedications[i, 1]);
                DGVMedications[1, i].Value = Convert.ToInt32(dataMedications[i, 2]);
            }
        }
Пример #2
0
        public Dictionary <int, string> GetPrescriptionsMedications()
        {
            query = Commands.SelectPrescriptionsMedications();
            ConnectedData.SetCommand(query);
            Dictionary <int, string> list = new Dictionary <int, string>();

            if (connectionType == ConnectionTypes.Connected)
            {
                int[] size = new int[2];
                size = ConnectedData.GetRowAndColumnCount();
                int row    = size[0];
                int column = size[1];

                string[,] data = new string[row, column];
                data           = ConnectedData.GetTableData();

                int    key = Convert.ToInt32(data[0, 0]);
                string str = "";

                for (int i = 0; i < row; i++)
                {
                    if (Convert.ToInt32(data[i, 0]) == key)
                    {
                        str += data[i, 1] + " " + data[i, 2] + "шт, ";
                    }
                    else
                    {
                        str = str.Remove(str.Length - 2);
                        list.Add(key, str);
                        str  = "";
                        key  = Convert.ToInt32(data[i, 0]);
                        str += data[i, 1] + " " + data[i, 2] + "шт, ";
                    }
                }
                str = str.Remove(str.Length - 2);
                list.Add(key, str);
            }

            else
            {
                dataSet = DisconnectedData.GetTableData(query);
                DataTable dataTable = dataSet.Tables[0];
                DataRow   dataRow   = dataTable.Rows[0];
                int       key       = Convert.ToInt32(dataRow[0]);
                string    str       = "";
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    dataRow = dataTable.Rows[i];
                    if (Convert.ToInt32(dataRow[0]) == key)
                    {
                        str += dataRow[1] + " " + dataRow[2] + "шт, ";
                    }
                    else
                    {
                        str = str.Remove(str.Length - 2);
                        list.Add(key, str);
                        str  = "";
                        key  = Convert.ToInt32(dataRow[0]);
                        str += dataRow[1] + " " + dataRow[2] + "шт, ";
                    }
                }
                str = str.Remove(str.Length - 2);
                list.Add(key, str);
            }
            return(list);
        }
Пример #3
0
        public void PrescriptionsPrint(SortTypes sort, string name = "")
        {
            PrescriptionsListView.Items.Clear();
            if (name != "")
            {
                query = Commands.SelectPrescriptions(sort, name);
            }
            else
            {
                query = Commands.SelectPrescriptions(sort);
            }
            ListViewItem item;

            if (connectionType == ConnectionTypes.Connected)
            {
                ConnectedData.SetCommand(query);
                int[] size = new int[2];
                size = ConnectedData.GetRowAndColumnCount();
                int row    = size[0];
                int column = size[1];
                string[,] data = new string[row, column];
                data           = ConnectedData.GetTableData();
                Dictionary <int, string> list  = GetPrescriptionsDiagnoses();
                Dictionary <int, string> list2 = GetPrescriptionsMedications();
                for (int i = 0; i < row; i++)
                {
                    item = new ListViewItem(data[i, 0]);
                    for (int j = 1; j < column; j++)
                    {
                        if (j == 4 || j == 5)
                        {
                            bool value = Convert.ToBoolean(data[i, j]);
                            if (value == true)
                            {
                                item.SubItems.Add("+");
                            }
                            else
                            {
                                item.SubItems.Add("-");
                            }
                        }

                        else
                        {
                            item.SubItems.Add(data[i, j]);
                        }
                    }

                    if (list.ContainsKey(Convert.ToInt32(data[i, 0])))
                    {
                        item.SubItems.Add(list[Convert.ToInt32(data[i, 0])]);
                    }
                    else
                    {
                        item.SubItems.Add("-");
                    }

                    if (list2.ContainsKey(Convert.ToInt32(data[i, 0])))
                    {
                        item.SubItems.Add(list2[Convert.ToInt32(data[i, 0])]);
                    }
                    else
                    {
                        item.SubItems.Add("-");
                    }

                    PrescriptionsListView.Items.Add(item);
                }
            }
            else
            {
                dataSet = DisconnectedData.GetTableData(query);
                DataTable dataTable = dataSet.Tables[0];
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    DataRow dataRow = dataTable.Rows[i];
                    item = new ListViewItem(dataRow[0].ToString());
                    for (int j = 1; j < dataTable.Columns.Count; j++)
                    {
                        if (j == 4 || j == 5)
                        {
                            bool value = Convert.ToBoolean(dataRow[j]);
                            if (value == true)
                            {
                                item.SubItems.Add("+");
                            }
                            else
                            {
                                item.SubItems.Add("-");
                            }
                        }

                        else
                        {
                            item.SubItems.Add(dataRow[j].ToString());
                        }
                    }
                    Dictionary <int, string> list  = GetPrescriptionsDiagnoses();
                    Dictionary <int, string> list2 = GetPrescriptionsMedications();
                    if (list.ContainsKey(Convert.ToInt32(dataRow[0])))
                    {
                        item.SubItems.Add(list[Convert.ToInt32(dataRow[0])]);
                    }
                    else
                    {
                        item.SubItems.Add("-");
                    }

                    if (list2.ContainsKey(Convert.ToInt32(dataRow[0])))
                    {
                        item.SubItems.Add(list2[Convert.ToInt32(dataRow[0])]);
                    }
                    else
                    {
                        item.SubItems.Add("-");
                    }
                    PrescriptionsListView.Items.Add(item);
                }
            }
        }
Пример #4
0
        public void MedicationsPrint(SortTypes sort, string name = "")
        {
            double sum          = 0;
            int    countPills   = 0;
            int    countSolutes = 0;

            MedicationsListView.Items.Clear();
            if (name != "")
            {
                query = Commands.SelectMedications(sort, name);
            }
            else
            {
                query = Commands.SelectMedications(sort);
            }
            ListViewItem item;

            if (connectionType == ConnectionTypes.Connected)
            {
                ConnectedData.SetCommand(query);
                int[] size = new int[2];
                size = ConnectedData.GetRowAndColumnCount();
                int row    = size[0];
                int column = size[1];

                string[,] data = new string[row, column];
                data           = ConnectedData.GetTableData();

                for (int i = 0; i < row; i++)
                {
                    item = new ListViewItem(data[i, 0]);
                    for (int j = 1; j < column; j++)
                    {
                        if (j == 2)
                        {
                            double value = Convert.ToDouble(data[i, j]);
                            item.SubItems.Add(Math.Round(value, 2).ToString() + " грн");
                            sum += value;
                        }

                        else
                        {
                            item.SubItems.Add(data[i, j]);
                        }
                        if (j == 5 && data[i, j] == "Таблетки")
                        {
                            countPills++;
                        }
                        else if (j == 5 && data[i, j] == "Раствор")
                        {
                            countSolutes++;
                        }
                    }
                    MedicationsListView.Items.Add(item);
                }
            }

            else
            {
                dataSet = DisconnectedData.GetTableData(query);
                DataTable dataTable = dataSet.Tables[0];
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    DataRow dataRow = dataTable.Rows[i];
                    item = new ListViewItem(dataRow[0].ToString());
                    for (int j = 1; j < dataTable.Columns.Count; j++)
                    {
                        if (j == 2)
                        {
                            double value = Convert.ToDouble(dataRow[j]);
                            item.SubItems.Add(Math.Round(value, 2).ToString() + " грн");
                            sum += value;
                        }

                        else
                        {
                            item.SubItems.Add(dataRow[j].ToString());
                        }
                        if (j == 5 && dataRow[j].ToString() == "Таблетки")
                        {
                            countPills++;
                        }
                        else if (j == 5 && dataRow[j].ToString() == "Раствор")
                        {
                            countSolutes++;
                        }
                    }
                    MedicationsListView.Items.Add(item);
                }
            }


            LabelMedicationsSumPriceValue.Text   = Math.Round(sum, 2).ToString() + " грн";
            LabelMedicationsSumPillsValue.Text   = countPills.ToString();
            LabelMedicationsSumSolutesValue.Text = countSolutes.ToString();
        }
Пример #5
0
        public void StorehouseFPrint(SortTypes sort, string name = "")
        {
            StorehouseFListView.Items.Clear();
            if (name != "")
            {
                query = Commands.SelectStorehouseF(sort, name);
            }
            else
            {
                query = Commands.SelectStorehouseF(sort);
            }
            ListViewItem item;

            if (connectionType == ConnectionTypes.Connected)
            {
                ConnectedData.SetCommand(query);
                int[] size = new int[2];
                size = ConnectedData.GetRowAndColumnCount();
                int row    = size[0];
                int column = size[1];
                string[,] data = new string[row, column];
                data           = ConnectedData.GetTableData();

                for (int i = 0; i < row; i++)
                {
                    item = new ListViewItem(data[i, 0]);

                    for (int j = 1; j < column; j++)
                    {
                        if (j == 5 || j == 6)
                        {
                            DateTime value = Convert.ToDateTime(data[i, j]);
                            item.SubItems.Add(value.ToShortDateString());
                        }

                        else
                        {
                            item.SubItems.Add(data[i, j]);
                        }
                    }
                    StorehouseFListView.Items.Add(item);
                }
            }
            else
            {
                dataSet = DisconnectedData.GetTableData(query);
                DataTable dataTable = dataSet.Tables[0];
                for (int i = 0; i < dataTable.Rows.Count; i++)
                {
                    DataRow dataRow = dataTable.Rows[i];
                    item = new ListViewItem(dataRow[0].ToString());
                    for (int j = 1; j < dataTable.Columns.Count; j++)
                    {
                        if (j == 5 || j == 6)
                        {
                            DateTime value = Convert.ToDateTime(dataRow[j]);
                            item.SubItems.Add(value.ToShortDateString());
                        }

                        else
                        {
                            item.SubItems.Add(dataRow[j].ToString());
                        }
                    }
                    StorehouseFListView.Items.Add(item);
                }
            }
        }