Esempio n. 1
0
        public void Update(IncomeReceipt data)
        {
            using (MySqlConnection conn = context.GetConnection())
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand("UPDATE `IncomeReceipt` SET `IssueDate`=@IssueDate,`ReceiveFrom`=@ReceiveFrom,`Remark`=@Remark,`Amount`=@Amount WHERE `Id`=@Id", conn);
                cmd.Parameters.AddWithValue("@IssueDate", data.IssueDate);
                cmd.Parameters.AddWithValue("@ReceiveFrom", data.ReceiveFrom);
                cmd.Parameters.AddWithValue("@Remark", data.Remark);
                cmd.Parameters.AddWithValue("@Amount", data.Amount);
                cmd.Parameters.AddWithValue("@Id", data.Id);

                cmd.ExecuteNonQuery();
            }
        }
Esempio n. 2
0
        public int Insert(IncomeReceipt data)
        {
            using (MySqlConnection conn = context.GetConnection())
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand("INSERT INTO `IncomeReceipt` VALUES (0,@IssueDate,@ReceiveFrom,@Remark,@Amount,@CreatedDate)", conn);
                cmd.Parameters.AddWithValue("@IssueDate", data.IssueDate);
                cmd.Parameters.AddWithValue("@ReceiveFrom", data.ReceiveFrom);
                cmd.Parameters.AddWithValue("@Remark", data.Remark);
                cmd.Parameters.AddWithValue("@Amount", data.Amount);
                cmd.Parameters.AddWithValue("@CreatedDate", DateTime.UtcNow);

                cmd.ExecuteNonQuery();
                return((int)cmd.LastInsertedId);
            }
        }