private void button1_Click(object sender, EventArgs e) { RUNNING rn = new RUNNING(); rn.ID = Convert.ToInt32(textBox_id.Text); float hasWithdraw = (float)_paid + float.Parse(textBox_withdraw.Text); decimal decimalValue = Math.Round((decimal)hasWithdraw, 2); rn.Withdraw = (float)decimalValue; int percent = (int)((hasWithdraw / _deposit) * 100); rn.Percent = percent; // BUS_RUNNING buss = new BUS_RUNNING(); int result = buss.UpdateRUNNING(rn); if (result != 0) { //insert to WithdrawHistory WithdrawHistoryMODEL with = new WithdrawHistoryMODEL(); with.ID = rn.ID; with.WithDraw = float.Parse(textBox_withdraw.Text); with.DateWithdraw = DateTime.Now.ToString(); // BUS_WithdrawHistory busswith = new BUS_WithdrawHistory(); int errorcode = busswith.InsertWithdrawHistory(with); if (errorcode != 0) { MessageBox.Show("Success!"); this.Close(); _p_form.LoadData("PAYING"); } } }
public int InsertWithdrawHistory(WithdrawHistoryMODEL with) { int result = 0; try { result = conector.InsertTableWithdrawHistory(with); return(result); } catch (Exception ex) { throw ex; } }
public int InsertTableWithdrawHistory(WithdrawHistoryMODEL web) { try { string sql = "insert into WithdrawHistory values(" + web.ID + "," + web.WithDraw + ",'" + web.DateWithdraw + "') "; cmd = new SqlCommand(sql); cmd.Connection = conn; this.openConnection(); int result = cmd.ExecuteNonQuery(); this.closeConnection(); return(result); } catch (Exception ex) { throw ex; } }