コード例 #1
0
        public void SavePurchase(SalesReciepts sale)
        {
            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("SavePurchase", cn);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlParameter param = new SqlParameter("@SalesReceiptId", SqlDbType.Int);
                param.Direction = ParameterDirection.Output;

                cmd.Parameters.Add(param);

                cmd.Parameters.AddWithValue("@VehicleId", sale.VehicleId);
                cmd.Parameters.AddWithValue("@CustomerId", sale.CustomerId);

                cmd.Parameters.AddWithValue("@EmployeeId", sale.EmployeeId);
                cmd.Parameters.AddWithValue("@PaymentMethodId", sale.PaymentMethodId);
                cmd.Parameters.AddWithValue("@Total", sale.Total);
                cmd.Parameters.AddWithValue("@Date", sale.Date);

                cn.Open();

                cmd.ExecuteNonQuery();

                sale.SalesRecieptsId = (int)param.Value;
            }
        }
コード例 #2
0
ファイル: AdoTests.cs プロジェクト: keeps1516/Dealership
        public void CanAddReciept()
        {
            var repo = new PurchaseRepositoryADO();

            var reciept = new SalesReciepts();

            reciept.CustomerId      = 1;
            reciept.Date            = DateTime.Now;
            reciept.EmployeeId      = 1;
            reciept.PaymentMethodId = 1;
            reciept.Total           = 30000;
            reciept.VehicleId       = 1;

            repo.SavePurchase(reciept);

            Assert.AreEqual(1, 1);
        }