Пример #1
0
        public static Slip GetSlip(int ID)
        {
            SqlConnection conn    = new SqlConnection();
            Slip          SlipObj = new Slip();

            try
            {
                conn = MariaDB.GetConnection();
                string sql = "SELECT [ID],[Width],[Length],[DockID] FROM [dbo].[Slip]" +
                             " WHERE [ID]= " + ID;
                SqlCommand cmd = new SqlCommand(sql, conn);

                SqlDataReader dr = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    SlipObj.ID     = Convert.ToInt32(dr["ID"]);
                    SlipObj.Width  = Convert.ToInt32(dr["Width"].ToString());
                    SlipObj.Length = Convert.ToInt32(dr["Length"]);
                    SlipObj.DockID = Convert.ToInt32(dr["DockID"]);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error : " + ex.ToString());
            }
            finally
            {
                conn.Close();
            }
            return(SlipObj);
        }
Пример #2
0
        public static List <Slip> GetAllAvailableDock()
        {
            SqlConnection conn    = new SqlConnection();
            List <Slip>   lstSlip = new List <Slip>();
            Slip          SlipObj;

            try
            {
                conn = MariaDB.GetConnection();
                string sql = "SELECT [Slip].[ID] AS SlipID,[Slip].[Width],[Slip].[Length],[Slip].[DockID] " + //,[Dock].[Name] AS DockName" +
                             " FROM [dbo].[Slip]" +
                             " JOIN [dbo].[Dock] ON [dbo].[Dock].[ID] = [dbo].[Slip].[DockID]" +
                             " WHERE [Slip].[ID] NOT IN(SELECT[Lease].[SlipID] FROM [dbo].[Lease] WHERE [Lease].[SlipID] = [Slip].[ID])";
                SqlCommand cmd = new SqlCommand(sql, conn);

                SqlDataReader dr = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
                while (dr.Read())
                {
                    SlipObj        = new Slip();
                    SlipObj.ID     = Convert.ToInt32(dr["SlipID"]);
                    SlipObj.Width  = Convert.ToInt32(dr["Width"]);
                    SlipObj.Length = Convert.ToInt32(dr["Length"]);
                    SlipObj.DockID = Convert.ToInt32(dr["DockID"]);
                    //SlipObj.DockName = Convert.ToString(dr["DockName"]);

                    lstSlip.Add(SlipObj);
                }
            }
            catch (Exception ex) {
                MessageBox.Show("Error : " + ex.ToString());
            }
            finally
            {
                conn.Close();
            }
            return(lstSlip);
        }