Exemplo n.º 1
0
        public List<TransactionModel> GetAllTransaction()
        {
            List<TransactionModel> transactionlList =new List<TransactionModel>();
              string url = @"server=faruk\SQLEXPRESS; database=ShopManagement; integrated security=true";
              SqlConnection connection = new SqlConnection(url);

              connection.Open();

              string query = "select * from t_transaction";
              SqlCommand command = new SqlCommand(query, connection);
              SqlDataReader aReader = command.ExecuteReader();

              int count = 1;
              if (aReader.HasRows)
              {
              while (aReader.Read())
              {
                  TransactionModel transaction = new TransactionModel();
                  transaction.Id = Convert.ToInt32((count++).ToString());
                  transaction.Name = aReader[1].ToString();
                  transaction.Date = Convert.ToDateTime(aReader[2].ToString());
                  transaction.Quantity= Convert.ToDouble((string)aReader[3]);
                  transaction.TotalPrice =  Convert.ToDouble(aReader[4].ToString());
                  transaction.PaidPrice =  Convert.ToDouble(aReader[5].ToString());
                  transactionlList.Add(transaction);
              }

              }
              connection.Close();
              return transactionlList;
        }
Exemplo n.º 2
0
 public string Save(TransactionModel atransaction)
 {
     if (atransaction.Name == string.Empty || atransaction.Date.ToString() == string.Empty )
       {
       return "Please Fill all field";
       }
       else
       {
       return gateway.Save(atransaction);
       }
 }
Exemplo n.º 3
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            TransactionModel atransaction=new TransactionModel();
            atransaction.Name = nameTextBox.Text;
            atransaction.Date = dateTimePicker.Value;
            atransaction.Quantity = Convert.ToDouble(quantityTextBox.Text);
            atransaction.TotalPrice = Convert.ToDouble(totalPrice.Text);
            atransaction.PaidPrice = Convert.ToDouble(paidPrice.Text);
            string msg = transactionBll.Save(atransaction);
            MessageBox.Show(msg);

            SeeAll();
        }
Exemplo n.º 4
0
        public string Save(TransactionModel atransaction)
        {
            string url = @"server=faruk\SQLEXPRESS; database=ShopManagement; integrated security=true";
              SqlConnection connection = new SqlConnection(url);

              connection.Open();

              string query = string.Format("insert into t_transaction values ('{0}','{1}','{2}','{3}','{4}')",
              atransaction.Name, atransaction.Date, atransaction.Quantity,atransaction.TotalPrice,atransaction.PaidPrice);
              SqlCommand command = new SqlCommand(query, connection);

              int affectedrow = command.ExecuteNonQuery();

              if (affectedrow > 0)
              return "Data inserted";
              return "Some Error";
        }