コード例 #1
0
ファイル: WageDao.cs プロジェクト: dobro3000/Reklama-manager
        public void Update(Wage wage)
        {
            try
            {
                using (var conn = GetConnection())
                {
                    conn.Open();
                    using (var cmd = conn.CreateCommand())
                    {
                        cmd.CommandText = "UPDATE Wage SET  CurrentSum = @CurrentSum,  Paid=@Paid, Rest=@Rest, SumOrders=@SumOrders WHERE IDManager = @ID1";
                        //cmd.Parameters.AddWithValue("@IDWage", wage.IDWage);
                        cmd.Parameters.AddWithValue("@ID1", wage.Manager);

                        object decease1 = wage.CurrentSum.HasValue ? (object)wage.CurrentSum.Value : DBNull.Value;
                        cmd.Parameters.AddWithValue("@CurrentSum", decease1);

                        object decease2 = wage.Paid.HasValue ? (object)wage.Paid.Value : DBNull.Value;
                        cmd.Parameters.AddWithValue("@Paid", decease2);

                        object decease3 = wage.Rest.HasValue ? (object)wage.Rest.Value : DBNull.Value;
                        cmd.Parameters.AddWithValue("@Rest", decease3);

                        object decease4 = wage.SumOrders.HasValue ? (object)wage.SumOrders.Value : DBNull.Value;
                        cmd.Parameters.AddWithValue("@SumOrders", decease4);
                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Ошибка");
            }
        }
コード例 #2
0
ファイル: WageDao.cs プロジェクト: dobro3000/Reklama-manager
        public void Add(Wage wage)
        {
            try
            {
                using (var conn = GetConnection())
                {
                    conn.Open();
                    using (var cmd = conn.CreateCommand())
                    {
                        cmd.CommandText = "INSERT INTO Wage(CurrentSum, IDManager, Paid, Rest, SumOrders) VALUES(@CurrentSum, @IDManager, @Paid, @Rest, @SumOrders)";
                        cmd.Parameters.AddWithValue("@IDManager", wage.Manager);

                        object decease1 = wage.CurrentSum.HasValue ? (object)wage.CurrentSum.Value : DBNull.Value;
                        cmd.Parameters.AddWithValue("@CurrentSum", decease1);

                        object decease2 = wage.Paid.HasValue ? (object)wage.Paid.Value : DBNull.Value;
                        cmd.Parameters.AddWithValue("@Paid", decease2);

                        object decease3 = wage.Rest.HasValue ? (object)wage.Rest.Value : DBNull.Value;
                        cmd.Parameters.AddWithValue("@Rest", decease3);

                        object decease4 = wage.SumOrders.HasValue ? (object)wage.SumOrders.Value : DBNull.Value;
                        cmd.Parameters.AddWithValue("@SumOrders", decease4);
                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Ошибка");
            }
        }
コード例 #3
0
ファイル: WageDao.cs プロジェクト: dobro3000/Reklama-manager
        private static Wage LoadWage(SqlDataReader reader)
        {
            Wage wage = new Wage();

            try
            {
                //wage.CurrentSum = (float)reader.GetDouble(reader.GetOrdinal("CurrentSum"));
                wage.Manager = reader.GetInt32(reader.GetOrdinal("IDManager"));
                //wage.Paid = (float)reader.GetDouble(reader.GetOrdinal("Paid"));
                //wage.Rest = (float)reader.GetDouble(reader.GetOrdinal("Rest"));
                //wage.SumOrders = reader.GetInt32(reader.GetOrdinal("SumOrders"));

                object decease1 = reader["Paid"];
                if (decease1 != DBNull.Value)
                {
                    wage.Paid = (float)Convert.ToDouble(decease1);
                }

                object decease2 = reader["Rest"];
                if (decease2 != DBNull.Value)
                {
                    wage.Rest = (float)Convert.ToDouble(decease2);
                }

                object decease3 = reader["SumOrders"];
                if (decease3 != DBNull.Value)
                {
                    wage.SumOrders = Convert.ToInt32(decease3);
                }

                object decease4 = reader["CurrentSum"];
                if (decease4 != DBNull.Value)
                {
                    wage.CurrentSum = (float)Convert.ToDouble(decease4);
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Ошибка.");
            }

            return(wage);
        }