예제 #1
0
        public NewDistillationForm()
        {
            InitializeComponent();

            Season season = AdministrationLogic.GetActiveSeason();
            Period period = AdministrationLogic.GetActivePeriod();

            _distillation = new Distillation
            {
                StartTime = DateTime.Now,
                Date      = DateTime.Today.Date,
                Payed     = false,
                Season    = season,
                Season_Id = season.Id,
                Period    = period,
                Period_Id = period.Id
            };

            _reqTBs = new List <TextBox>
            {
                tbAmount,
                tbDistVolume,
                tbPercAlc
            };


            materialCB.DataSource    = MaterialLogic.GetAllMaterial();
            materialCB.DisplayMember = "Name";



            tbPeriod.Text = period.Name;
            tbSeason.Text = season.Name;
        }
예제 #2
0
        private static void PrepareCommand(SqlCommand sqlCom, Distillation distillation)
        {
            sqlCom.Parameters.AddWithValue("@Id", distillation.Id);
            sqlCom.Parameters.AddWithValue("@date", distillation.Date);
            sqlCom.Parameters.AddWithValue("@startTime", distillation.StartTime);
            sqlCom.Parameters.AddWithValue("@endTime", distillation.EndTime);
            sqlCom.Parameters.AddWithValue("@amount", distillation.Amount);
            sqlCom.Parameters.AddWithValue("@ethanolPercentage", distillation.EthanolPercentage);
            sqlCom.Parameters.AddWithValue("@distilledVolume", distillation.DistilledVolume);
            sqlCom.Parameters.AddWithValue("@absoluteAlcoholVolume", distillation.AbsoluteAlcoholVolume);
            sqlCom.Parameters.AddWithValue("@price", distillation.Price);
            if (distillation.Payed)
            {
                sqlCom.Parameters.AddWithValue("@payed", 1);
            }
            else
            {
                sqlCom.Parameters.AddWithValue("@payed", 0);
            }

            sqlCom.Parameters.AddWithValue("@Customer_Id", distillation.Customer_Id);
            sqlCom.Parameters.AddWithValue("@Material_Id", distillation.Material_Id);
            sqlCom.Parameters.AddWithValue("@Season_Id", distillation.Season_Id);
            sqlCom.Parameters.AddWithValue("@Period_Id", distillation.Period_Id);
        }
예제 #3
0
        private static Collection <Distillation> Read(SqlDataReader reader)
        {
            Collection <Distillation> distillations = new Collection <Distillation>();

            while (reader.Read())
            {
                Distillation d = new Distillation();
                int          i = -1;
                d.Id                    = reader.GetInt32(++i);
                d.Date                  = reader.GetDateTime(++i);
                d.StartTime             = reader.GetDateTime(++i);
                d.EndTime               = reader.GetDateTime(++i);
                d.Amount                = reader.GetDouble(++i);
                d.EthanolPercentage     = reader.GetDouble(++i);
                d.DistilledVolume       = reader.GetDouble(++i);
                d.AbsoluteAlcoholVolume = reader.GetDouble(++i);
                d.Price                 = reader.GetDouble(++i);
                d.Payed                 = reader.GetBoolean(++i);
                d.Customer_Id           = reader.GetInt32(++i);
                d.Material_Id           = reader.GetInt32(++i);
                d.Season_Id             = reader.GetInt32(++i);
                d.Period_Id             = reader.GetInt32(++i);


                distillations.Add(d);
            }
            return(distillations);
        }
예제 #4
0
 public static int Insert(Distillation distillation)
 {
     using (SqlServerDatabase db = new SqlServerDatabase())
     {
         SqlCommand sqlCom = db.CreateCommand(SQL_INSERT);
         PrepareCommand(sqlCom, distillation);
         return(db.ExecuteNonQuery(sqlCom));
     }
 }
예제 #5
0
        public static bool CanBeDeleted(Distillation distillation)
        {
            DateTime tenYearsAgo = DateTime.Now.AddYears(-10);

            if (distillation.Date <= tenYearsAgo)
            {
                return(true);
            }

            return(false);
        }
예제 #6
0
        public static int CreateDistillation(Distillation distillation)
        {
            IDatabase db = Configuration.GetDatabase();

            Season season = distillation.Season;

            season.DistillationCount += 1;
            db.Update(season);

            return(db.Insert(distillation));
        }
예제 #7
0
 public DistillationDetail(int distillationId)
 {
     InitializeComponent();
     _distillation = DistillationLogic.GetDistillation(distillationId);
 }
예제 #8
0
        public static int DeleteDistillation(Distillation distillation)
        {
            IDatabase db = Configuration.GetDatabase();

            return(db.Delete(distillation));
        }