예제 #1
0
        public static List<UslugiCategory> GetCategoryList()
        {
            List<UslugiCategory> listNG = new List<UslugiCategory>();
            try
            {
                if ((connection != null) && (connection.State == ConnectionState.Closed))
                    connection = OpenConnection();
                else
                    connection = OpenConnection();
                SqlDataReader reader = null;
                if (connection != null)
                {

                    SqlCommand ngCommand = connection.CreateCommand();
                    ngCommand.CommandType = CommandType.StoredProcedure;
                    ngCommand.CommandText = GET_CATEGORIES_REGISRTY;
                    // ngCommand.CommandTimeout = CommandTimeOut > 2 * connection.ConnectionTimeout ? CommandTimeOut : 2 * connection.ConnectionTimeout;
                    try
                    {
                        reader = ngCommand.ExecuteReader();
                        while (reader.Read())
                        {
                            string category = (string)reader["Name"];
                            int id = (int)reader["ID"];
                            string description = (string)reader["Description"];
                            UslugiCategory categoryItem = new UslugiCategory();
                            categoryItem.Name = category;
                            categoryItem.ID = id;
                            categoryItem.Description = description;
                            categoryItem.ParentID = -1;
                            categoryItem.Description = description;
                            listNG.Add(categoryItem);

                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        CloseConnection();
                        return null;
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                CloseConnection();
            }
            CloseConnection();
            return listNG;
        }
예제 #2
0
 public void EditAnalizeItem()
 {
     int[] selected = gridViewJournal.GetSelectedRows();
     if (selected.Length == 1)
     {
         JournalItem journalItem = ((JournalItem)gridViewJournal.GetRow(selected[0]));
         int clientId = journalItem.ID_Client;
         int orgId = journalItem.ID_Org;
         List<JournalUslugiItem> journaluslugiitems = DataProvider.DataProvider.GetJournalUslugiItems(journalItem.ID);
         List<UslugiCategory> listUslugi = new List<UslugiCategory>();
         foreach (JournalUslugiItem jusl in journaluslugiitems)
            {
                UslugiCategory categusl = new UslugiCategory(jusl);
                listUslugi.Add(categusl);
            }
         EditUslugiVisitToJournalForm dlg = new EditUslugiVisitToJournalForm();
         dlg.SetInputForms(journalItem, listUslugi);
         dlg.ShowDialog();
         dlg.Hide();
     }
 }
예제 #3
0
        public static List<UslugiCategory> GetUslugiListBycategoryID(int CategoryId)
        {
            List<UslugiCategory> listNG = new List<UslugiCategory>();
            try
            {
                if ((connection != null) && (connection.State == ConnectionState.Closed))
                    connection = OpenConnection();
                else
                    connection = OpenConnection();
                SqlDataReader reader = null;
                if (connection != null)
                {

                    SqlCommand ngCommand = connection.CreateCommand();
                    ngCommand.CommandType = CommandType.StoredProcedure;
                    ngCommand.CommandText = GET_USLUGIBYCATEGORY_REGISRTY;
                    ngCommand.Parameters.AddWithValue("@categoryId", CategoryId);
                    // ngCommand.CommandTimeout = CommandTimeOut > 2 * connection.ConnectionTimeout ? CommandTimeOut : 2 * connection.ConnectionTimeout;
                    try
                    {
                        reader = ngCommand.ExecuteReader();
                        while (reader.Read())
                        {
                            string category = (string)reader["Name"];
                            object shame = reader["ShortName"];
                            string shortName =string.Empty;
                            if (shame!=null)
                             shortName =  (string)reader["ShortName"];
                            int id = (int)reader["ID"];
                            string description = (string)reader["Description"];
                            DateTime date = (DateTime)reader["Date"];
                            double price = (double)reader["Price"];
                            double kef = (double)reader["Kef"];
                            int parentId = -1;// (int)reader["ID_Category"];

                            UslugiCategory categoryItem = new UslugiCategory();
                            categoryItem.Name = category;
                            categoryItem.ID = id;
                            categoryItem.Description = description;
                            categoryItem.ParentID = parentId;
                            categoryItem.Price = price;
                            categoryItem.Date = date;
                            categoryItem.ShortName = shortName;
                            categoryItem.Kef = kef;
                               if (!DBNull.Value.Equals(reader["IsAnalize"]))
                                 categoryItem.IsAnalize = (bool)reader["IsAnalize"];
                            else
                                 categoryItem.IsAnalize=false;
                            listNG.Add(categoryItem);

                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        CloseConnection();
                        return null;
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                CloseConnection();
            }
            CloseConnection();
            return listNG;
        }