public bool ExcuteSQL(string sql) { bool i = true; try { OracleConnection conn = new OracleConnection(StaticFunctionData.ConnString); switch (conn.State.ToString() != "Open") { case true: conn.Open(); break; } OracleCommand cmd = new OracleCommand(sql, conn); cmd.ExecuteNonQuery(); //conn.Close(); } catch (Exception ex) { i = false; Console.WriteLine("ERROR ====>"); Console.WriteLine(sql); Console.WriteLine(ex.Message); GreeterFunction.Logs(ex.Message); Console.WriteLine("END ====>"); throw ex; } return(i); }
public DataSet GetFill(string sql) { DataSet dr = new DataSet(); try { OracleConnection conn = new OracleConnection(StaticFunctionData.ConnString); switch (conn.State.ToString() != "Open") { case true: conn.Open(); break; } OracleDataAdapter da = new OracleDataAdapter(sql, conn); da.Fill(dr); //conn.Close(); } catch (Exception ex) { Console.WriteLine("ERROR ====>"); Console.WriteLine(sql); Console.WriteLine(ex); GreeterFunction.Logs(ex.Message); Console.WriteLine("END ====>"); //throw ex; } return(dr); }
void UpdateContainer(BookingInvoicePallet pl) { try { string sql = $"select * from txp_loadcontainer where containerno = '{bbiContainer.EditValue.ToString().ToUpper()}'"; DateTime d = DateTime.Parse(bbiRelDate.EditValue.ToString()); string txttime = $"{d.ToString("dd/MM/yyyy")} {bbiRelTimer.EditValue.ToString().Substring(10, 9).Trim()}"; DateTime dx = DateTime.Parse(bbiEtd.EditValue.ToString()); string containersize = "20F"; if (bbi4oFt.Checked) { containersize = "40F"; } DataSet dr = new ConnDB().GetFill(sql); string sqlupdate = $"update txp_loadcontainer set etddte=to_date('{dx.ToString("dd/MM/yyyy")}', 'DD/MM/YYYY')," + $"sealno='{bbiSealNo.EditValue.ToString().ToUpper()}',containersize='{containersize}'," + $"receivedte=to_date('{d.ToString("dd/MM/yyyy")}', 'DD/MM/YYYY')," + $"releasedte=to_date('{txttime}', 'DD/MM/YYYY HH24:MI:SS'),upddte=sysdate\n" + $"where containerno='{bbiContainer.EditValue.ToString().ToUpper()}'"; if (dr.Tables[0].Rows.Count <= 0) { sqlupdate = "insert into txp_loadcontainer(containerno,custname,etddte,sealno,containersize,receivedte,releasedte,sysdte,upddte) \n" + "values \n" + $"('{bbiContainer.EditValue.ToString().ToUpper()}', " + $"'{pl.custname.Trim().ToUpper()}', " + $"to_date('{dx.ToString("dd/MM/yyyy")}', 'DD/MM/YYYY'), '{bbiSealNo.EditValue.ToString().ToUpper()}', " + $"'{containersize}', to_date('{d.ToString("dd/MM/yyyy")}', 'DD/MM/YYYY'), " + $"to_date('{txttime}', 'DD/MM/YYYY HH24:MI:SS'), sysdate, sysdate)"; } new ConnDB().ExcuteSQL(sqlupdate); new ConnDB().ExcuteSQL($"UPDATE TXP_LOADPALLET SET CONTAINERNO = '{bbiContainer.EditValue.ToString().ToUpper()}' WHERE PLOUTNO = '{pl.ploutno}'"); } catch (Exception ex) { GreeterFunction.Logs(ex.Message); } }