public static bool AddApplication(ATTApplication Applicationobj) { string InsertAppSQL = ""; InsertAppSQL = "SP_ADD_APPLICATIONS"; GetConnection GetConn = new GetConnection(); OracleTransaction Tran; try { OracleConnection DBConn = GetConn.GetDbConn(); Tran = DBConn.BeginTransaction(); OracleParameter[] paramArray = new OracleParameter[4]; paramArray[0] = Utilities.GetOraParam(":p_APPL_ID", Applicationobj.ApplicationID, OracleDbType.Int64, ParameterDirection.InputOutput); paramArray[1] = Utilities.GetOraParam(":p_DESCRIPTION", Applicationobj.ApplicationDescription, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[2] = Utilities.GetOraParam(":p_APPL_FULL_NAME", Applicationobj.ApplicationFullName, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[3] = Utilities.GetOraParam(":p_APPL_SHORT_NAME", Applicationobj.ApplicationShortName, OracleDbType.Varchar2, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, InsertAppSQL, paramArray[0], paramArray); double applicationID = double.Parse(paramArray[0].Value.ToString()); Tran.Commit(); return(true); } catch (Exception ex) { throw ex; } finally { GetConn.CloseDbConn(); } }
public static bool DeletePost(int PostID) { GetConnection Conn = new GetConnection(); OracleConnection DBConn; OracleTransaction Tran; string DeletePostSql = "SP_DEL_POST "; try { DBConn = Conn.GetDbConn(Module.DLPDS); Tran = DBConn.BeginTransaction(); OracleParameter[] ParamArray = new OracleParameter[1]; ParamArray[0] = Utilities.GetOraParam(":p_POST_ID", PostID, OracleDbType.Int64, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, DeletePostSql, ParamArray); Tran.Commit(); return(true); } catch (Exception ex) { throw ex; } }
public static bool DeleteLeaveType(int LeaveTypeID) { GetConnection Conn = new GetConnection(); OracleConnection DBConn; OracleTransaction Tran; string DeleteLeaveTypeSql = "SP_DEL_LEAVE_TYPES"; try { DBConn = Conn.GetDbConn(Module.PMS); Tran = DBConn.BeginTransaction(); OracleParameter[] ParamArray = new OracleParameter[1]; ParamArray[0] = Utilities.GetOraParam(":p_LEAVE_TYPE_ID", LeaveTypeID, OracleDbType.Int64, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, DeleteLeaveTypeSql, ParamArray); Tran.Commit(); return(true); } catch (Exception ex) { throw ex; } finally { Conn.CloseDbConn(); } }
public void Commit() { if (!IsTransaction) { throw new BDException("尚未启用事务或已经关闭"); } Tran.Commit(); }
/// <summary> /// 提交事务 /// </summary> public void Commit() { if (IsTran) { IsTran = false; Tran.Commit(); Dispose(); } }
public static bool SaveEmpRetirement(List <ATTRetirement> LSTRet) { OracleTransaction Tran; GetConnection conn = new GetConnection(); OracleConnection DBConn = conn.GetDbConn(Module.PMS); Tran = DBConn.BeginTransaction(); string InsertUpDel = ""; try { foreach (ATTRetirement var in LSTRet) { if (var.action == "A") { InsertUpDel = "SP_ADD_EMP_RETIREMENT"; } else if (var.action == "E") { InsertUpDel = "SP_EDIT_EMP_RETIREMENT"; } if (var.action == "A" || var.action == "E") { List <OracleParameter> paramArray = new List <OracleParameter>(); paramArray.Add(Utilities.GetOraParam("p_emp_id", var.empID, OracleDbType.Int32, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("p_org_id", var.orgID, OracleDbType.Int32, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("p_des_id", var.desID, OracleDbType.Int32, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("p_created_date", var.createdDate, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("p_post_id", var.postID, OracleDbType.Int32, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("p_from_date", var.fromDate, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("p_retirement_date", var.retirementDate, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("p_is_self", var.isSelf, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("p_retirement_type", var.retirementType, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("p_retirement_desc", var.ApplDesc, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("p_decision_date", var.decisionDate, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("p_decision_by", var.decisionBy, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("p_app_date", var.appDate, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("p_app_by", var.appBy, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("p_entry_by", var.entryBy, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("p_decision_desc", var.decisionDesc, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("p_app_desc", var.appDesc, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("p_is_decided", var.isDecided, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("p_is_approved", var.isApproved, OracleDbType.Varchar2, ParameterDirection.Input)); DataSet ds = SqlHelper.ExecuteDataset(DBConn, CommandType.StoredProcedure, InsertUpDel, paramArray.ToArray()); } } } catch (Exception ex) { Tran.Rollback(); throw ex; } Tran.Commit(); return(true); }
public static bool SaveAward(List <ATTAwardPunishment> LSTAward) { OracleTransaction Tran; GetConnection conn = new GetConnection(); OracleConnection DBConn = conn.GetDbConn(Module.PMS); Tran = DBConn.BeginTransaction(); string InsertUpdateDelete = ""; try { foreach (ATTAwardPunishment var in LSTAward) { if (var.Action == "A") { InsertUpdateDelete = "SP_ADD_EMP_AWARDS"; } else if (var.Action == "E") { InsertUpdateDelete = "SP_EDIT_EMP_AWARDS"; } else if (var.Action == "D") { InsertUpdateDelete = "SP_DEL_EMP_AWARDS"; } if (var.Action == "A" || var.Action == "E") { List <OracleParameter> paramArray = new List <OracleParameter>(); paramArray.Add(Utilities.GetOraParam("P_EMP_ID", var.EmpID, OracleDbType.Double, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("P_SEQ_NO", var.SequenceNo, OracleDbType.Int32, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("P_AWARD ", var.Award, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("P_AWARD_DATE", var.AwardDate, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("P_VERIFIED_BY", var.VerifiedBy, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("P_VERIFIED_DATE", var.VerifiedDate, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("P_REMARKS", var.Remarks, OracleDbType.Varchar2, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("P_ENTRY_BY", var.EntryBy, OracleDbType.Varchar2, ParameterDirection.Input)); DataSet ds = SqlHelper.ExecuteDataset(DBConn, CommandType.StoredProcedure, InsertUpdateDelete, paramArray.ToArray()); } else if (var.Action == "D") { List <OracleParameter> paramArray = new List <OracleParameter>(); paramArray.Add(Utilities.GetOraParam("P_EMP_ID", var.EmpID, OracleDbType.Double, ParameterDirection.Input)); paramArray.Add(Utilities.GetOraParam("P_SEQ_NO", var.SequenceNo, OracleDbType.Int32, ParameterDirection.Input)); DataSet ds = SqlHelper.ExecuteDataset(DBConn, CommandType.StoredProcedure, InsertUpdateDelete, paramArray.ToArray()); } } } catch (Exception ex) { Tran.Rollback(); throw ex; } Tran.Commit(); return(true); }
public static bool AddOrgUsers(ATTOrganizationUsers obj) { PCS.COREDL.GetConnection Conn = new GetConnection(); OracleConnection DBConn; OracleTransaction Tran; DBConn = Conn.GetDbConn(); Tran = DBConn.BeginTransaction(); try { string InsertUpdateSP = ""; if (obj.ObjUsers != null) { DLLUsers.AddUsers(obj.ObjUsers, Tran); } if (obj.Action == "A") { InsertUpdateSP = "SP_ADD_ORG_USERS"; } else { InsertUpdateSP = "SP_EDIT_ORG_USERS"; } OracleParameter[] ParamArray = new OracleParameter[3]; ParamArray[0] = Utilities.GetOraParam(":p_Org_ID", obj.OrgID, OracleDbType.Varchar2, ParameterDirection.Input); ParamArray[1] = Utilities.GetOraParam(":p_User_name", obj.Username, OracleDbType.Varchar2, ParameterDirection.Input); ParamArray[2] = Utilities.GetOraParam(":p_From_Date", obj.FromDate, OracleDbType.Varchar2, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, InsertUpdateSP, ParamArray); if (obj.LSTUserRoles != null) { DLLUserRoles.AddUserRoles(obj.LSTUserRoles, Tran); } Tran.Commit(); return(true); } catch (System.Exception ex) { //OracleError Tran.Rollback(); throw ex; } finally { Conn.CloseDbConn(); } }
public static bool SaveLeaveTypeDesignation(List <ATTLeaveTypeDesignation> lstLeaveTypeDesignation) { GetConnection Conn = new GetConnection(); OracleConnection DBConn = Conn.GetDbConn(Module.PMS); string SaveLeaveTypeDesignationSQL = ""; OracleTransaction Tran; Tran = DBConn.BeginTransaction(); try { foreach (ATTLeaveTypeDesignation ObjAtt in lstLeaveTypeDesignation) { if (ObjAtt.Action == "A") { SaveLeaveTypeDesignationSQL = "SP_ADD_LEAVE_TYPE_DESG"; } else if (ObjAtt.Action == "E") { SaveLeaveTypeDesignationSQL = "SP_EDIT_LEAVE_TYPE_DESG"; } if (ObjAtt.Action != "" && ObjAtt.Action != null && ObjAtt.Action != "D") { OracleParameter[] ParamArray = new OracleParameter[10]; ParamArray[0] = Utilities.GetOraParam(":P_LEAVE_TYPE_ID", ObjAtt.LeaveTypeID, OracleDbType.Int64, ParameterDirection.Input); ParamArray[1] = Utilities.GetOraParam(":P_DES_ID", ObjAtt.DesignationID, OracleDbType.Int64, ParameterDirection.Input); ParamArray[2] = Utilities.GetOraParam(":P_FROM_DATE", ObjAtt.EffectiveFromDate, OracleDbType.Varchar2, ParameterDirection.Input); ParamArray[3] = Utilities.GetOraParam(":P_NO_OF_DAYS", ObjAtt.Days, OracleDbType.Int64, ParameterDirection.Input); ParamArray[4] = Utilities.GetOraParam(":P_PERIOD_TYPE", ObjAtt.PeriodType, OracleDbType.Varchar2, ParameterDirection.Input); ParamArray[5] = Utilities.GetOraParam(":P_PERIOD_TIMES", ObjAtt.PeriodTimes, OracleDbType.Int64, ParameterDirection.Input); ParamArray[6] = Utilities.GetOraParam(":P_IS_ACCRUAL", (ObjAtt.IsAccural ? "Y" : "N"), OracleDbType.Varchar2, ParameterDirection.Input); ParamArray[7] = Utilities.GetOraParam(":P_ACCRUAL_DAYS", ObjAtt.AccuralDays, OracleDbType.Int64, ParameterDirection.Input); ParamArray[8] = Utilities.GetOraParam(":P_ACTIVE", (ObjAtt.Active ? "Y" : "N"), OracleDbType.Varchar2, ParameterDirection.Input); ParamArray[9] = Utilities.GetOraParam(":P_ENTRY_BY", ObjAtt.EntryBy, OracleDbType.Varchar2, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(DBConn, CommandType.StoredProcedure, SaveLeaveTypeDesignationSQL, ParamArray); } } Tran.Commit(); return(true); } catch (Exception ex) { Tran.Rollback(); throw ex; } finally { Conn.CloseDbConn(); } }
private void button1_Click(object sender, EventArgs e) { cFunciones fun = new Clases.cFunciones(); if (fun.ValidarFecha(txtFechaCobro.Text) == false) { Mensaje("La fecha de cobro es incorrecta"); return; } DateTime FechaCobro = Convert.ToDateTime(txtFechaCobro.Text); if (Grilla.CurrentRow == null) { Mensaje("Debe seleccionar un elemento para continuar"); return; } string sFechaCobro = Grilla.CurrentRow.Cells[5].Value.ToString(); if (sFechaCobro != "") { Mensaje("Ya se ha cobrado el registro"); return; } Double Importe = 0; cCuentaCorriente cuenta = new cCuentaCorriente(); cMovimiento mov = new cMovimiento(); string Descripcion = "Cobro de Cuenta Corriente "; Descripcion = Descripcion + " " + Grilla.CurrentRow.Cells[1].Value.ToString(); Int32 CodOrden = Convert.ToInt32(Grilla.CurrentRow.Cells[6].Value.ToString()); SqlConnection con = new SqlConnection(cConexion.Cadenacon()); con.Open(); SqlTransaction Tran; Tran = con.BeginTransaction(); try { Importe = fun.ToDouble(Grilla.CurrentRow.Cells[3].Value.ToString()); mov.GrabarMovimientoTransaccion(con, Tran, Importe, Descripcion, FechaCobro, Principal.CodUsuarioLogueado, CodOrden); cuenta.ActualizarFechacobro(con, Tran, Convert.ToInt32(CodOrden), FechaCobro); Tran.Commit(); con.Close(); Mensaje("Datos grabados correctamente"); Buscar(); } catch (Exception ex) { Tran.Rollback(); con.Close(); Mensaje("Hubo un error en el proceso de grabacion"); throw; } }
private void button4_Click(object sender, EventArgs e) { // 선택된 행 데이터 저장 if (dgvGridC.Rows.Count == 0) { return; //-- 저장할 행이 없으면 리턴하라 } if (MessageBox.Show("선택된 데이터를 등록 하시겠습니까?", "데이터등록", MessageBoxButtons.YesNo) == DialogResult.No) { return; } string cCustCode = dgvGridC.CurrentRow.Cells["CUSTCODE"].Value.ToString(); string cCustType = dgvGridC.CurrentRow.Cells["CUSTTYPE"].Value.ToString(); string cCustName = dgvGridC.CurrentRow.Cells["CUSTNAME"].Value.ToString(); string cBizClass = dgvGridC.CurrentRow.Cells["BIZCLASS"].Value.ToString(); string cBizType = dgvGridC.CurrentRow.Cells["BIZTYPE"].Value.ToString(); string cUseFlag = dgvGridC.CurrentRow.Cells["USEFLAG"].Value.ToString(); string cProdDate = dgvGridC.CurrentRow.Cells["FIRSTDATE"].Value.ToString(); SqlCommand cmd = new SqlCommand(); SqlTransaction Tran; Connect = new SqlConnection(strConn); Connect.Open(); Tran = Connect.BeginTransaction("TestTran"); cmd.Transaction = Tran; cmd.Connection = Connect; //두 개를 한번에 처리하는함수 cmd.CommandText = "UPDATE TB_CUST_KJW " + " SET CUSTCODE = '" + cCustCode + "', " + " CUSTTYPE = '" + cCustType + "', " + " CUSTNAME = '" + cCustName + "', " + " BIZCLASS = '" + cBizClass + "', " + " BIZTYPE = '" + cBizType + "', " + " USEFLAG = '" + cUseFlag + "', " + " FIRSTDATE = '" + cProdDate + "', " + " EDITDATE = GETDATE() ," + " EDITOR = '" + Common.LogInId + "' " + " WHERE CUSTCODE = '" + cCustCode + "' " + " IF (@@ROWCOUNT =0) " + "INSERT INTO TB_CUST_KJW(CUSTCODE, CUSTTYPE, CUSTNAME, BIZCLASS, BIZTYPE, USEFLAG, FIRSTDATE, EDITDATE , EDITOR) " + "VALUES('" + cCustCode + "','" + cCustType + "','" + cCustName + "','" + cBizClass + "','" + cBizType + "','" + cUseFlag + "','" + cProdDate + "',GETDATE(),'" + Common.LogInId + "')"; cmd.ExecuteNonQuery(); //위에작성한쿼리를 실행하라 // 성공 시 DB COMMIT Tran.Commit(); MessageBox.Show("정상적으로 등록하였습니다."); Connect.Close(); }
private void SaveShift() { SqlTransaction Tran; if (MessageBox.Show(string.Format(SaveConfirmText, "Shift"), MessageBoxCaption, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No) { return; } try { using (SqlConnection Conn = new SqlConnection(GlobalClass.TConnectionString)) { Conn.Open(); Tran = Conn.BeginTransaction(); try { shift.SHIFT_ID = Conn.ExecuteScalar <byte>("SELECT CAST(ISNULL(MAX(SHIFT_ID), 0) + 1 AS SMALLINT) FROM tblShift", transaction: Tran); if (shift.Save(Tran)) { GlobalClass.SetUserActivityLog(Tran, "Attendant Shift", "New", WorkDetail: "SHIFT_ID : " + shift.SHIFT_ID, Remarks: shift.SHIFT_NAME); Tran.Commit(); MessageBox.Show("Shift Saved Successfully.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Information); ShiftList.Add(new Shift { SHIFT_ID = shift.SHIFT_ID, SHIFT_NAME = shift.SHIFT_NAME, SHIFT_START = shift.SHIFT_START, UID = GlobalClass.User.UID, SHIFT_STATUS = shift.SHIFT_STATUS, SHIFT_END = shift.SHIFT_END }); ExecuteUndo(null); } else { MessageBox.Show("shift Type could not be Saved.", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Exclamation); Tran.Rollback(); } } catch (SqlException ex) { if (Tran.Connection != null) { Tran.Rollback(); } if (ex.Number == 2601) { MessageBox.Show("Entered shift name already exist in the database. Enter unique name and try again", MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Hand); } MessageBox.Show(ex.Number + " : " + ex.Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error); } } } catch (Exception ex) { MessageBox.Show(ex.Message, MessageBoxCaption, MessageBoxButton.OK, MessageBoxImage.Error); } }
public static bool SaveDegreeLevel(ATTDegreeLevel ObjAtt) { GetConnection Conn = new GetConnection(); OracleConnection DBConn; OracleTransaction Tran; string InsertUpdateDegreeLevel = ""; try { DBConn = Conn.GetDbConn(); Tran = DBConn.BeginTransaction(); if (ObjAtt.DegreeLevelID == 0) { InsertUpdateDegreeLevel = "SP_ADD_DEGREE_LEVEL"; } else { InsertUpdateDegreeLevel = "SP_EDIT_DEGREE_LEVEL"; } OracleParameter[] ParamArray = new OracleParameter[4]; ParamArray[0] = Utilities.GetOraParam(":p_DEGREE_LEVEL_ID", ObjAtt.DegreeLevelID, OracleDbType.Int64, ParameterDirection.InputOutput); ParamArray[1] = Utilities.GetOraParam(":p_DEGREE_LEVEL_NAME", ObjAtt.DegreeLevelName, OracleDbType.Varchar2, ParameterDirection.Input); ParamArray[2] = Utilities.GetOraParam(":p_ACTIVE", ObjAtt.Active, OracleDbType.Varchar2, ParameterDirection.Input); ParamArray[3] = Utilities.GetOraParam(":p_ENTRY_BY", ObjAtt.EntryBy, OracleDbType.Varchar2, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, InsertUpdateDegreeLevel, ParamArray); int DegreeLevelID = int.Parse(ParamArray[0].Value.ToString()); //if (ObjAtt.DegreeLevelID == 0) ObjAtt.DegreeLevelID = DegreeLevelID; DLLDegree.SaveDegree(ObjAtt.LstDegree, DegreeLevelID, Tran); Tran.Commit(); return(true); } catch (Exception ex) { throw ex; } finally { Conn.CloseDbConn(); } }
public void Dispose() { if (Exceptions.Count > 0) { Tran.Rollback(); } else { DBContext.SaveChanges(); Tran.Commit(); } Tran.Dispose(); }
public static bool SavePost(ATTPost ObjAtt) { GetConnection Conn = new GetConnection(); OracleConnection DBConn; OracleTransaction Tran; string InsertUpdatePostSql = ""; try { DBConn = Conn.GetDbConn(Module.DLPDS); Tran = DBConn.BeginTransaction(); if (ObjAtt.PostID == 0) { InsertUpdatePostSql = "SP_ADD_POST"; } else { InsertUpdatePostSql = "SP_EDIT_POST"; } OracleParameter[] ParamArray = new OracleParameter[2]; ParamArray[0] = Utilities.GetOraParam(":p_POST_ID", ObjAtt.PostID, OracleDbType.Int64, ParameterDirection.InputOutput); ParamArray[1] = Utilities.GetOraParam(":p_POST_NAME", ObjAtt.PostName, OracleDbType.Varchar2, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, InsertUpdatePostSql, ParamArray); int PostID = int.Parse(ParamArray[0].Value.ToString()); ObjAtt.PostID = PostID; DLLPostLevel.SavePostLevel(ObjAtt.LstPostLevel, Tran, PostID); Tran.Commit(); return(true); } catch (Exception ex) { throw ex; } finally { Conn.CloseDbConn(); } }
public static bool SaveDesignation(ATTDesignation ObjAtt) { GetConnection Conn = new GetConnection(); OracleConnection DBConn; OracleTransaction Tran; string InsertUpdateDesignation = ""; try { DBConn = Conn.GetDbConn(Module.PMS); Tran = DBConn.BeginTransaction(); if (ObjAtt.DesignationID == 0) { InsertUpdateDesignation = "SP_ADD_DESIGNATIONS"; } else { InsertUpdateDesignation = "SP_EDIT_DESIGNATIONS"; } OracleParameter[] ParamArray = new OracleParameter[5]; ParamArray[0] = Utilities.GetOraParam(":p_DES_ID", ObjAtt.DesignationID, OracleDbType.Int64, ParameterDirection.InputOutput); ParamArray[1] = Utilities.GetOraParam(":p_DESG_NAME", ObjAtt.DesignationName, OracleDbType.Varchar2, ParameterDirection.Input); ParamArray[2] = Utilities.GetOraParam(":p_DESG_TYPE", ObjAtt.DesignationType, OracleDbType.Varchar2, ParameterDirection.Input); ParamArray[3] = Utilities.GetOraParam(":p_SERVICE_PERIOD", ObjAtt.ServicePeriod, OracleDbType.Int32, ParameterDirection.Input); ParamArray[4] = Utilities.GetOraParam(":p_AGE_LIMIT", ObjAtt.AgeLimit, OracleDbType.Int32, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, InsertUpdateDesignation, ParamArray); int DesgID = int.Parse(ParamArray[0].Value.ToString()); ObjAtt.DesignationID = DesgID; Tran.Commit(); return(true); } catch (Exception ex) { throw ex; } finally { Conn.CloseDbConn(); } }
public void CommitTransaction() { /* * 仅限 组件外 调用。 */ if (Tran == null) { throw XConfig.EC.Exception(XConfig.EC._088, "请检查: 1-上下文是否已调用【void BeginTransaction()】开启事务!; 2-在事务范围内使用的【XConnection】对象是否为同一实例!"); } Tran.Commit(); if (AutoClose) { Conn.Close(); } }
public static bool SaveJudgeWorkInspection(ATTJudgeWorkInspection objAtt) { string InsertUpdateSP = ""; OracleTransaction Tran; if (objAtt.Action == "A") { InsertUpdateSP = "SP_ADD_JUDGE_WORK_INSPECTION"; } else if (objAtt.Action == "E") { InsertUpdateSP = "SP_EDIT_JUDGE_WORK_INSPECTION"; } OracleParameter[] ParamArray = new OracleParameter[5]; ParamArray[0] = FRAMEWORK.Utilities.GetOraParam(":P_EMP_ID", objAtt.EmployeeID, OracleDbType.Int64, ParameterDirection.Input); ParamArray[1] = FRAMEWORK.Utilities.GetOraParam(":P_FISCAL_YEAR", objAtt.FiscalYear, OracleDbType.Varchar2, ParameterDirection.Input); ParamArray[2] = FRAMEWORK.Utilities.GetOraParam(":P_INSP_EMP_ID", objAtt.InspEmpID, OracleDbType.Int64, ParameterDirection.Input); ParamArray[3] = FRAMEWORK.Utilities.GetOraParam(":P_INSP_DATE", objAtt.InspectionDate, OracleDbType.Date, ParameterDirection.Input); ParamArray[4] = FRAMEWORK.Utilities.GetOraParam(":P_ENTRY_BY", objAtt.EntryBy, OracleDbType.Varchar2, ParameterDirection.Input); GetConnection GetConn = new GetConnection(); OracleConnection DBConn = GetConn.GetDbConn(Module.PMS); Tran = DBConn.BeginTransaction(); try { SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, InsertUpdateSP, ParamArray); DLLJudgeWorkInspectionDetails.SaveJudgeWorkInspectionDetails(objAtt.Details, Tran); Tran.Commit(); return(true); } catch (Exception ex) { Tran.Rollback(); throw ex; } finally { GetConn.CloseDbConn(); } }
public static bool LeaveApprove(ATTEmployeeLeave var) { OracleTransaction Tran; GetConnection conn = new GetConnection(); OracleConnection DBConn = conn.GetDbConn(Module.PMS); Tran = DBConn.BeginTransaction(); try { string InsertUpdateDLSP = "SP_LEAVE_APPROVE"; OracleParameter[] paramArray = new OracleParameter[16]; paramArray[0] = Utilities.GetOraParam("P_IS_OTHERS", null, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[1] = Utilities.GetOraParam(":P_EMP_ID", var.EmpID, OracleDbType.Int32, ParameterDirection.Input); paramArray[2] = Utilities.GetOraParam(":P_LEAVE_TYPE_ID", var.LeaveTypeID, OracleDbType.Int32, ParameterDirection.Input); paramArray[3] = Utilities.GetOraParam(":P_APPL_DATE", var.ApplDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[4] = Utilities.GetOraParam(":P_APP_BY", var.AppByID, OracleDbType.Int32, ParameterDirection.Input); paramArray[5] = Utilities.GetOraParam(":P_APP_DATE", var.AppDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[6] = Utilities.GetOraParam(":P_APP_FROM_DATE", var.AppFrom, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[7] = Utilities.GetOraParam(":P_APP_TO_DATE", var.AppTo, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[8] = Utilities.GetOraParam(":P_APP_NO_OF_DAYS", var.AppDays, OracleDbType.Int32, ParameterDirection.Input); paramArray[9] = Utilities.GetOraParam(":P_APP_YES_NO", var.Approved, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[10] = Utilities.GetOraParam(":P_APP_REASON", var.AppReason, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[11] = Utilities.GetOraParam(":P_LEAVE_FY", null, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[12] = Utilities.GetOraParam("P_LEAVE_PERIOD_UNIT", null, OracleDbType.Int32, ParameterDirection.Input); paramArray[13] = Utilities.GetOraParam("P_PERIOD_TYPE", null, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[14] = Utilities.GetOraParam("P_PERIOD_COUNT", null, OracleDbType.Int32, ParameterDirection.Input); paramArray[15] = Utilities.GetOraParam("P_LEAVE_TAKEN_CNT", null, OracleDbType.Int32, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, InsertUpdateDLSP, paramArray); Tran.Commit(); } catch (Exception ex) { Tran.Rollback(); throw ex; } finally { DBConn.Close(); } return(true); }
public static bool SaveLeaveType(ATTLeaveType ObjAtt) { GetConnection Conn = new GetConnection(); OracleConnection DBConn; OracleTransaction Tran; string InsertUpdateLeaveType = ""; try { DBConn = Conn.GetDbConn(Module.PMS); Tran = DBConn.BeginTransaction(); if (ObjAtt.LeaveTypeID == 0) { InsertUpdateLeaveType = "SP_ADD_LEAVE_TYPES"; } else { InsertUpdateLeaveType = "SP_EDIT_LEAVE_TYPES"; } OracleParameter[] ParamArray = new OracleParameter[4]; ParamArray[0] = Utilities.GetOraParam(":p_LEAVE_TYPE_ID", ObjAtt.LeaveTypeID, OracleDbType.Int64, ParameterDirection.InputOutput); ParamArray[1] = Utilities.GetOraParam(":p_LEAVE_TYPE_NAME", ObjAtt.LeaveTypeName, OracleDbType.Varchar2, ParameterDirection.Input); ParamArray[2] = Utilities.GetOraParam(":p_GENDER", ObjAtt.Gender, OracleDbType.Varchar2, ParameterDirection.Input); ParamArray[3] = Utilities.GetOraParam(":p_ACTIVE", ObjAtt.Active, OracleDbType.Varchar2, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, InsertUpdateLeaveType, ParamArray); int LeaveTypeID = int.Parse(ParamArray[0].Value.ToString()); ObjAtt.LeaveTypeID = LeaveTypeID; Tran.Commit(); return(true); } catch (Exception ex) { throw ex; } finally { Conn.CloseDbConn(); } }
public static bool SaveEmpWorkDivision(List <ATTEmployeeWorkDivision> LSTEmpWrkDiv) { OracleTransaction Tran; GetConnection conn = new GetConnection(); OracleConnection DBConn = conn.GetDbConn(Module.PMS); Tran = DBConn.BeginTransaction(); try { string InsertUpdateDLSP = ""; foreach (ATTEmployeeWorkDivision var in LSTEmpWrkDiv) { if (var.Action == "A") { InsertUpdateDLSP = "SP_ADD_EMP_WORK_DIST"; } OracleParameter[] paramArray = new OracleParameter[11]; paramArray[0] = Utilities.GetOraParam(":P_EMP_ID", var.EmpID, OracleDbType.Double, ParameterDirection.Input); paramArray[1] = Utilities.GetOraParam(":P_ORG_ID", var.OrgID, OracleDbType.Int32, ParameterDirection.Input); paramArray[2] = Utilities.GetOraParam(":P_DES_ID", var.DesID, OracleDbType.Int32, ParameterDirection.Input); paramArray[3] = Utilities.GetOraParam(":P_CREATED_DATE", var.CreatedDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[4] = Utilities.GetOraParam(":P_POST_ID", var.PostID, OracleDbType.Int32, ParameterDirection.Input); paramArray[5] = Utilities.GetOraParam(":P_FROM_DATE", var.FromDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[6] = Utilities.GetOraParam(":P_UNIT_ID", var.OrgUnitID, OracleDbType.Int32, ParameterDirection.Input); paramArray[7] = Utilities.GetOraParam(":P_UNIT_FROM_DATE", var.UnitFromDate, OracleDbType.Varchar2, ParameterDirection.Input); //paramArray[7] = Utilities.GetOraParam(":P_SECTION_ID", var.SectionID, OracleDbType.Int32, ParameterDirection.Input); //paramArray[8] = Utilities.GetOraParam(":P_SEC_FROM_DATE", var.SectionFromDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[8] = Utilities.GetOraParam(":P_RESPONSIBILITY", var.Responsibility, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[9] = Utilities.GetOraParam(":P_UNIT_HEAD", var.IsHeadOfUnit, OracleDbType.Varchar2, ParameterDirection.Input); // paramArray[11] = Utilities.GetOraParam(":P_SECTION_HEAD", var.IsHeadOfSection, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[10] = Utilities.GetOraParam(":P_ENTRY_BY", var.EntryBy, OracleDbType.Varchar2, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, InsertUpdateDLSP, paramArray); } } catch (Exception ex) { Tran.Rollback(); throw ex; } Tran.Commit(); return(true); }
public static bool SaveOrgUnitHead(ATTOrgUnitHead objOrgUnitHead) { OracleTransaction Tran; GetConnection conn = new GetConnection(); OracleConnection DBConn = conn.GetDbConn(Module.PMS); Tran = DBConn.BeginTransaction(); try { string InsertUpdateDLSP = ""; if (objOrgUnitHead.Action == "A") { InsertUpdateDLSP = "SP_ADD_ORG_UNIT_HEAD"; } //else if (objOrgUnitHead.Action == "E") // InsertUpdateDLSP = "SP_EDIT_ORG_UNIT_HEAD"; OracleParameter[] paramArray = new OracleParameter[8]; paramArray[0] = Utilities.GetOraParam(":P_ORG_ID", objOrgUnitHead.OrgID, OracleDbType.Int32, ParameterDirection.Input); paramArray[1] = Utilities.GetOraParam(":P_UNIT_ID", objOrgUnitHead.UnitID, OracleDbType.Int32, ParameterDirection.Input); paramArray[2] = Utilities.GetOraParam(":P_EMP_ID", objOrgUnitHead.EmpID, OracleDbType.Double, ParameterDirection.Input); paramArray[3] = Utilities.GetOraParam(":P_FROM_DATE", objOrgUnitHead.FromDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[4] = Utilities.GetOraParam(":P_TO_DATE", objOrgUnitHead.ToDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[5] = Utilities.GetOraParam(":P_UNIT_HEAD", objOrgUnitHead.UnitHead, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[6] = Utilities.GetOraParam(":P_OFFICE_HEAD", objOrgUnitHead.OfficeHead, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[7] = Utilities.GetOraParam(":P_ENTRY_BY", objOrgUnitHead.EntryBY, OracleDbType.Varchar2, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, InsertUpdateDLSP, paramArray); } catch (Exception ex) { Tran.Rollback(); throw ex; } Tran.Commit(); return(true); }
private void btnSave_Click(object sender, EventArgs e) { //선택된 행 데이터 저장 if (dgvGrid.Rows.Count == 0) { return; } if (dgvGrid.CurrentRow.Cells[0].Value.ToString() == "" || dgvGrid.CurrentRow.Cells[1].Value.ToString() == "" || dgvGrid.CurrentRow.Cells[6].Value.ToString() == "") { MessageBox.Show("거래처코드 및 거래처 타입, 거래 일자는 반드시 입력해주세요"); return; } else { if (MessageBox.Show("선택된 데이터를 등록하시겠습니까?", "데이터등록 ", MessageBoxButtons.YesNo) == DialogResult.No) { return; } String custCode = dgvGrid.CurrentRow.Cells["CUSTCODE"].Value.ToString(); String custType = dgvGrid.CurrentRow.Cells["CUSTTYPE"].Value.ToString(); String custName = dgvGrid.CurrentRow.Cells["CUSTNAME"].Value.ToString(); String bizClass = dgvGrid.CurrentRow.Cells["BIZCLASS"].Value.ToString(); String bizType = dgvGrid.CurrentRow.Cells["BIZTYPE"].Value.ToString(); String useFlag = dgvGrid.CurrentRow.Cells["USEFLAG"].Value.ToString(); String firstDate = dgvGrid.CurrentRow.Cells["FIRSTDATE"].Value.ToString(); if (custType == "고객사" || custType == "C") { custType = "C"; } else { custType = "V"; } if (useFlag == "사용" || useFlag == "Y") { useFlag = "Y"; } else { useFlag = "N"; } SqlCommand cmd = new SqlCommand(); SqlTransaction Tran; Connect = new SqlConnection(strCon); Connect.Open(); //Transaction 설정 Tran = Connect.BeginTransaction("TestTran"); cmd.Transaction = Tran; cmd.Connection = Connect; cmd.CommandText = "UPDATE TB_CUST_KBM " + " SET CUSTNAME = '" + custName + "', " + " BIZCLASS = '" + bizClass + "', " + " BIZTYPE = '" + bizType + "', " + " USEFLAG = '" + useFlag + "', " + " FIRSTDATE = '" + firstDate + "', " + " EDITDATE = GETDATE() , " + " EDITOR = '" + Common.LogInId + "' " + " WHERE CUSTCODE = '" + custCode + "'" + " AND CUSTTYPE = '" + custType + "'" + "IF (@@ROWCOUNT = 0)" + "INSERT INTO TB_CUST_KBM (CUSTCODE, CUSTTYPE, CUSTNAME, BIZCLASS, BIZTYPE, USEFLAG, FIRSTDATE, MAKEDATE, MAKER)" + " VALUES('" + custCode + "','" + custType + "','" + custName + "','" + bizClass + "','" + bizType + "','" + useFlag + "','" + firstDate + "', GETDATE() ,'" + Common.LogInId + "');"; cmd.ExecuteNonQuery(); //성공 시 DB COMMIT Tran.Commit(); MessageBox.Show("정상적으로 등록하였씁니다."); Connect.Close(); } }
public static bool SaveEmpLeaveApplication(List <ATTEmployeeLeave> LSTEmpLeave) { OracleTransaction Tran; GetConnection conn = new GetConnection(); OracleConnection DBConn = conn.GetDbConn(Module.PMS); Tran = DBConn.BeginTransaction(); try { string InsertUpdateDLSP = ""; foreach (ATTEmployeeLeave var in LSTEmpLeave) { if (var.Action == "A") { InsertUpdateDLSP = "SP_ADD_LEAVE_APPL_EMP"; } else if (var.Action == "E") { InsertUpdateDLSP = "SP_EDIT_LEAVE_APPL_EMP"; } else if (var.Action == "D") { InsertUpdateDLSP = "SP_DEL_LEAVE_APPL_EMP"; } if (var.Action == "A" || var.Action == "E" || var.Action == "D") { OracleParameter[] paramArray = new OracleParameter[22]; paramArray[0] = Utilities.GetOraParam(":P_EMP_ID", var.EmpID, OracleDbType.Int32, ParameterDirection.Input); paramArray[1] = Utilities.GetOraParam(":P_APPL_DATE", var.ApplDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[2] = Utilities.GetOraParam(":P_LEAVE_TYPE_ID", var.LeaveTypeID, OracleDbType.Int32, ParameterDirection.Input); paramArray[3] = Utilities.GetOraParam(":P_REQ_FROM_DATE", var.ReqdFrom, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[4] = Utilities.GetOraParam(":P_REQ_TO_DATE", var.ReqdTo, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[5] = Utilities.GetOraParam(":P_REQ_NO_OF_DAYS", var.EmpDays, OracleDbType.Int32, ParameterDirection.Input); paramArray[6] = Utilities.GetOraParam(":P_REQ_REASON", var.EmpReason, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[7] = Utilities.GetOraParam(":P_REC_BY", var.RecByID, OracleDbType.Int32, ParameterDirection.Input); paramArray[8] = Utilities.GetOraParam(":P_REC_DATE", var.RecDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[9] = Utilities.GetOraParam(":P_REC_FROM_DATE", var.RecFrom, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[10] = Utilities.GetOraParam(":P_REC_TO_DATE", var.RecTo, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[11] = Utilities.GetOraParam(":P_REC_NO_OF_DAYS", var.RecDays, OracleDbType.Int32, ParameterDirection.Input); paramArray[12] = Utilities.GetOraParam(":P_REC_YES_NO", var.Recommended, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[13] = Utilities.GetOraParam(":P_REC_REASON", var.RecReason, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[14] = Utilities.GetOraParam(":P_APP_BY", var.AppByID, OracleDbType.Int32, ParameterDirection.Input); paramArray[15] = Utilities.GetOraParam(":P_APP_DATE", var.AppDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[16] = Utilities.GetOraParam(":P_APP_FROM_DATE", var.AppFrom, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[17] = Utilities.GetOraParam(":P_APP_TO_DATE", var.AppTo, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[18] = Utilities.GetOraParam(":P_APP_NO_OF_DAYS", var.AppDays, OracleDbType.Int32, ParameterDirection.Input); paramArray[19] = Utilities.GetOraParam(":P_APP_YES_NO", var.Approved, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[20] = Utilities.GetOraParam(":P_APP_REASON", var.AppReason, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[21] = Utilities.GetOraParam(":P_ENTRY_BY", var.EntryBy, OracleDbType.Varchar2, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, InsertUpdateDLSP, paramArray); } } } catch (Exception ex) { Tran.Rollback(); throw ex; } Tran.Commit(); return(true); }
private void btnSaveC_Click(object sender, EventArgs e) { //선택된 행 데이터 저장 if (dgvCus.Rows.Count == 0) { return; } if (MessageBox.Show("선택된 데이터를 등록 하시겠습니까?", "데이터 등록", MessageBoxButtons.YesNo) == DialogResult.No) { return; } string sItemCode = dgvCus.CurrentRow.Cells["CUSTCODE"].Value.ToString(); string sItemName = dgvCus.CurrentRow.Cells["CUSTTYPE"].Value.ToString(); string sItemDesc = dgvCus.CurrentRow.Cells["CUSTNAME"].Value.ToString(); string sItemDesc2 = dgvCus.CurrentRow.Cells["BIZCLASS"].Value.ToString(); string sBType = dgvCus.CurrentRow.Cells["BIZTYPE"].Value.ToString(); string sItemEndFlag = dgvCus.CurrentRow.Cells["USEFLAG"].Value.ToString(); string sProdDate = dgvCus.CurrentRow.Cells["FIRSTDATE"].Value.ToString(); string sMakedate = dgvCus.CurrentRow.Cells["MAKEDATE"].Value.ToString(); string sMaker = dgvCus.CurrentRow.Cells["MAKER"].Value.ToString(); string sEditdate = dgvCus.CurrentRow.Cells["EDITDATE"].Value.ToString(); string sEditor = dgvCus.CurrentRow.Cells["EDITDATE"].Value.ToString(); SqlCommand cmd = new SqlCommand(); SqlTransaction Tran; Connect = new SqlConnection(strConn); Connect.Open(); //데이터 조회 후 해당 데이터가 있는지 확인 후 update, insert구문 분기 string sSql = "SELECT CUSTCODE FROM TB_CUSTOMER_MSW WHERE CUSTCODE = '" + sItemCode + "'"; SqlDataAdapter adapter = new SqlDataAdapter(sSql, Connect); DataTable dtTemp = new DataTable(); adapter.Fill(dtTemp); //트랜잭션 설정 Tran = Connect.BeginTransaction("TestTran"); cmd.Transaction = Tran; cmd.Connection = Connect; cmd.CommandText = "UPDATE TB_CUSTOMER_MSW " + " SET CUSTCODE = '" + sItemCode + "', " + " CUSTTYPE = '" + sItemName + "', " + " CUSTNAME = '" + sItemDesc + "', " + " BIZCLASS = '" + sItemDesc2 + "', " + " BIZTYPE = '" + sBType + "', " + " USEFLAG = '" + sItemEndFlag + "', " + " FIRSTDATE = '" + sProdDate + "', " + " MAKEDATE = '" + sMakedate + "', " + " MAKER = '" + sMaker + "', " + " EDITOR = '" + Common.LogInId + "', " + " EDITDATE = '" + DateTime.Now + "' " + " WHERE CUSTCODE = '" + sItemCode + "' " + " IF (@@ROWCOUNT =0) " + "INSERT INTO TB_CUSTOMER_MSW(CUSTCODE, CUSTTYPE, CUSTNAME, BIZCLASS, BIZTYPE , USEFLAG, FIRSTDATE, MAKEDATE, MAKER, EDITOR, EDITDATE) " + "VALUES('" + sItemCode + "','" + sItemName + "','" + sItemDesc + "','" + sItemDesc2 + "','" + sBType + "','" + sItemEndFlag + "','" + sProdDate + "','" + sMakedate + "','" + sMaker + "','" + Common.LogInId + "'," + " GETDATE())"; //e데이터가 잇는 경우 update, 없는 경우 insert //if (dtTemp.Rows.Count == 0) //{ // //데이터가 없으니 INSERT해라 // cmd.CommandText = "INSERT INTO TB_TESTITEM_MSW (ITEMCODE, ITEMNAME, ITEMDESC, ITEMDESC2, ENDFLAG, PRODDATE, MAKEDATE, MAKER)" + // " VALUES ('" + sItemCode + "','" + sItemName + "','" + sItemDesc + "','" + sItemDesc2 + "','" + "N" + "','" + sProdDate + "',GETDATE(),'" + "" + "')"; //} //else //{ // //데이터가 있으니 UPDATE해라 // cmd.CommandText = "UPDATE TB_TESTITEM_MSW " + // " SET ITEMNAME = '" + sItemName + "', " + // " ITEMDESC = '" + sItemDesc + "', " + // " ITEMDESC2 = '" + sItemDesc2 + "', " + // " ENDFLAG = '" + "N" + "', " + // " PRODDATE = '" + sProdDate + "', " + // " EDITOR = '', " + // //" EDITOR = '" + Commoncs.LoginUserID + "', " + // " EDITDATE = GETDATE() " + // " WHERE ITEMCODE = '" + sItemCode + "'"; //} cmd.ExecuteNonQuery(); //성공시 DB COMMIT Tran.Commit(); MessageBox.Show("정상적으로 등록 하였습니다."); Connect.Close(); }
public static bool SaveItemsTransfer(List <ATTInvItemsTransfered> LSTItemsTrans, string opt) { OracleTransaction Tran; GetConnection conn = new GetConnection(); OracleConnection DBConn = conn.GetDbConn(Module.OAS); Tran = DBConn.BeginTransaction(); try { string InsertUpdateItemsTransfered = ""; foreach (ATTInvItemsTransfered var in LSTItemsTrans) { int itemTypeID = var.ItemsTypeID; if (var.Action == "A") { InsertUpdateItemsTransfered = "SP_INV_ADD_ITEMS_TRANSFER"; } else if (var.Action == "E") { InsertUpdateItemsTransfered = "SP_INV_EDIT_ITEMS_TRANSFER"; } if (opt == "transfer") { if (itemTypeID == 1) { if (var.Action == "A" || var.Action == "E") { OracleParameter[] paramArray = new OracleParameter[20]; paramArray[0] = Utilities.GetOraParam(":P_ORG_ID", var.OrgID, OracleDbType.Int32, ParameterDirection.Input); paramArray[1] = Utilities.GetOraParam(":P_ITEMS_CATEGORY_ID", var.ItemsCategoryID, OracleDbType.Int32, ParameterDirection.Input); paramArray[2] = Utilities.GetOraParam(":P_ITEMS_SUB_CATEGORY_ID", var.ItemsSubCategoryID, OracleDbType.Int32, ParameterDirection.Input); paramArray[3] = Utilities.GetOraParam(":P_ITEMS_ID", var.ItemsID, OracleDbType.Int32, ParameterDirection.Input); paramArray[4] = Utilities.GetOraParam(":P_TRFD_ORG", var.TransORG, OracleDbType.Int32, ParameterDirection.Input); paramArray[5] = Utilities.GetOraParam(":P_TRFD_SEQ", var.TransSEQ, OracleDbType.Int32, ParameterDirection.InputOutput); paramArray[6] = Utilities.GetOraParam(":P_QUANTITY", var.Quantity, OracleDbType.Int32, ParameterDirection.Input); paramArray[7] = Utilities.GetOraParam(":P_DECISION_DATE ", var.DecisionDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[8] = Utilities.GetOraParam(":P_TRFD_DATE", var.TransDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[9] = Utilities.GetOraParam(":P_TRFD_VIA", var.TransVia, OracleDbType.Int32, ParameterDirection.Input); paramArray[10] = Utilities.GetOraParam(":P_TRFD_RCVD_BY", var.TransRecvBy, OracleDbType.Int32, ParameterDirection.Input); paramArray[11] = Utilities.GetOraParam(":P_TRFD_ORG_UNIT", var.TransOrgUnit, OracleDbType.Int32, ParameterDirection.Input); paramArray[12] = Utilities.GetOraParam(":P_TRFD_TO", var.TransTo, OracleDbType.Int32, ParameterDirection.Input); paramArray[13] = Utilities.GetOraParam(":P_TRFD_RCVD_DATE", var.TransRecvDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[14] = Utilities.GetOraParam(":P_RETURN_BY", var.ReturnBy, OracleDbType.Int32, ParameterDirection.Input); paramArray[15] = Utilities.GetOraParam(":P_RETURN_DATE", var.ReturnDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[16] = Utilities.GetOraParam(":P_RETURN_VIA", var.ReturnVia, OracleDbType.Int32, ParameterDirection.Input); paramArray[17] = Utilities.GetOraParam(":P_RETURN_RCVD_BY", var.ReturnRecvBy, OracleDbType.Int32, ParameterDirection.Input); paramArray[18] = Utilities.GetOraParam(":P_RETURN_RCVD_DATE", var.ReturnRecvDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[19] = Utilities.GetOraParam(":P_ENTRY_BY", var.EntryBy, OracleDbType.Varchar2, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, InsertUpdateItemsTransfered, paramArray); var.TransSEQ = int.Parse(paramArray[5].Value.ToString()); } } else if (itemTypeID == 2) { if (var.Action == "A") { InsertUpdateItemsTransfered = "SP_INV_ADD_ITEMS_TRANSFER_KNJ"; } else if (var.Action == "E") { InsertUpdateItemsTransfered = "SP_INV_EDIT_ITEMS_TRANSFER_KNJ"; } if (var.Action == "A" || var.Action == "E") { OracleParameter[] paramArr = new OracleParameter[20]; paramArr[0] = Utilities.GetOraParam(":P_ORG_ID", var.OrgID, OracleDbType.Int32, ParameterDirection.Input); paramArr[1] = Utilities.GetOraParam(":P_ITEMS_CATEGORY_ID", var.ItemsCategoryID, OracleDbType.Int32, ParameterDirection.Input); paramArr[2] = Utilities.GetOraParam(":P_ITEMS_SUB_CATEGORY_ID", var.ItemsSubCategoryID, OracleDbType.Int32, ParameterDirection.Input); paramArr[3] = Utilities.GetOraParam(":P_ITEMS_ID", var.ItemsID, OracleDbType.Int32, ParameterDirection.Input); paramArr[4] = Utilities.GetOraParam(":P_SEQ_NO", var.SeqNo, OracleDbType.Int32, ParameterDirection.Input); paramArr[5] = Utilities.GetOraParam(":P_TRFD_ORG", var.TransORG, OracleDbType.Int32, ParameterDirection.Input); paramArr[6] = Utilities.GetOraParam(":P_TRFD_SEQ", var.TransSEQ, OracleDbType.Int32, ParameterDirection.InputOutput); paramArr[7] = Utilities.GetOraParam(":P_DECISION_DATE", var.DecisionDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArr[8] = Utilities.GetOraParam(":P_TRFD_DATE", var.TransDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArr[9] = Utilities.GetOraParam(":P_TRFD_VIA", var.TransVia, OracleDbType.Int32, ParameterDirection.Input); paramArr[10] = Utilities.GetOraParam(":P_TRFD_RCVD_BY", var.TransRecvBy, OracleDbType.Int32, ParameterDirection.Input); paramArr[11] = Utilities.GetOraParam(":P_TRFD_ORG_UNIT", var.TransOrgUnit, OracleDbType.Int32, ParameterDirection.Input); paramArr[12] = Utilities.GetOraParam(":P_TRFD_TO", var.TransTo, OracleDbType.Int32, ParameterDirection.Input); paramArr[13] = Utilities.GetOraParam(":P_TRFD_RCVD_DATE", var.TransRecvDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArr[14] = Utilities.GetOraParam(":P_RETURN_BY", var.ReturnBy, OracleDbType.Int32, ParameterDirection.Input); paramArr[15] = Utilities.GetOraParam(":P_RETURN_DATE", var.ReturnDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArr[16] = Utilities.GetOraParam(":P_RETURN_VIA", var.ReturnVia, OracleDbType.Int32, ParameterDirection.Input); paramArr[17] = Utilities.GetOraParam(":P_RETURN_RCVD_BY", var.ReturnRecvBy, OracleDbType.Int32, ParameterDirection.Input); paramArr[18] = Utilities.GetOraParam(":P_RETURN_RCVD_DATE", var.ReturnRecvDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArr[19] = Utilities.GetOraParam(":P_ENTRY_BY", var.EntryBy, OracleDbType.Varchar2, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, InsertUpdateItemsTransfered, paramArr); var.TransSEQ = int.Parse(paramArr[6].Value.ToString()); } } } else if (opt == "receive") { if (itemTypeID == 1) { if (var.Action == "A" || var.Action == "E") { OracleParameter[] paramArray = new OracleParameter[20]; paramArray[0] = Utilities.GetOraParam(":P_ORG_ID", var.OrgID, OracleDbType.Int32, ParameterDirection.Input); paramArray[1] = Utilities.GetOraParam(":P_ITEMS_CATEGORY_ID", var.ItemsCategoryID, OracleDbType.Int32, ParameterDirection.Input); paramArray[2] = Utilities.GetOraParam(":P_ITEMS_SUB_CATEGORY_ID", var.ItemsSubCategoryID, OracleDbType.Int32, ParameterDirection.Input); paramArray[3] = Utilities.GetOraParam(":P_ITEMS_ID", var.ItemsID, OracleDbType.Int32, ParameterDirection.Input); paramArray[4] = Utilities.GetOraParam(":P_TRFD_ORG", var.TransORG, OracleDbType.Int32, ParameterDirection.Input); paramArray[5] = Utilities.GetOraParam(":P_TRFD_SEQ", var.TransSEQ, OracleDbType.Int32, ParameterDirection.InputOutput); paramArray[6] = Utilities.GetOraParam(":P_QUANTITY", var.Quantity, OracleDbType.Int32, ParameterDirection.Input); paramArray[7] = Utilities.GetOraParam(":P_DECISION_DATE ", var.DecisionDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[8] = Utilities.GetOraParam(":P_TRFD_DATE", var.TransDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[9] = Utilities.GetOraParam(":P_TRFD_VIA", var.TransVia, OracleDbType.Int32, ParameterDirection.Input); paramArray[10] = Utilities.GetOraParam(":P_TRFD_RCVD_BY", var.TransRecvBy, OracleDbType.Int32, ParameterDirection.Input); paramArray[11] = Utilities.GetOraParam(":P_TRFD_ORG_UNIT", var.TransOrgUnit, OracleDbType.Int32, ParameterDirection.Input); paramArray[12] = Utilities.GetOraParam(":P_TRFD_TO", var.TransTo, OracleDbType.Int32, ParameterDirection.Input); paramArray[13] = Utilities.GetOraParam(":P_TRFD_RCVD_DATE", var.TransRecvDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[14] = Utilities.GetOraParam(":P_RETURN_BY", var.ReturnBy, OracleDbType.Int32, ParameterDirection.Input); paramArray[15] = Utilities.GetOraParam(":P_RETURN_DATE", var.ReturnDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[16] = Utilities.GetOraParam(":P_RETURN_VIA", var.ReturnVia, OracleDbType.Int32, ParameterDirection.Input); paramArray[17] = Utilities.GetOraParam(":P_RETURN_RCVD_BY", var.ReturnRecvBy, OracleDbType.Int32, ParameterDirection.Input); paramArray[18] = Utilities.GetOraParam(":P_RETURN_RCVD_DATE", var.ReturnRecvDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[19] = Utilities.GetOraParam(":P_ENTRY_BY", var.EntryBy, OracleDbType.Varchar2, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, InsertUpdateItemsTransfered, paramArray); var.TransSEQ = int.Parse(paramArray[5].Value.ToString()); } } else if (itemTypeID == 2) { if (var.Action == "A") { InsertUpdateItemsTransfered = "SP_INV_ADD_ITEMS_TRANSFER_KNJ"; } else if (var.Action == "E") { InsertUpdateItemsTransfered = "SP_INV_EDIT_ITEMS_TRANSFER_KNJ"; } if (var.Action == "A" || var.Action == "E") { OracleParameter[] paramArr = new OracleParameter[20]; paramArr[0] = Utilities.GetOraParam(":P_ORG_ID", var.OrgID, OracleDbType.Int32, ParameterDirection.Input); paramArr[1] = Utilities.GetOraParam(":P_ITEMS_CATEGORY_ID", var.ItemsCategoryID, OracleDbType.Int32, ParameterDirection.Input); paramArr[2] = Utilities.GetOraParam(":P_ITEMS_SUB_CATEGORY_ID", var.ItemsSubCategoryID, OracleDbType.Int32, ParameterDirection.Input); paramArr[3] = Utilities.GetOraParam(":P_ITEMS_ID", var.ItemsID, OracleDbType.Int32, ParameterDirection.Input); paramArr[4] = Utilities.GetOraParam(":P_SEQ_NO", var.SeqNo, OracleDbType.Int32, ParameterDirection.Input); paramArr[5] = Utilities.GetOraParam(":P_TRFD_ORG", var.TransORG, OracleDbType.Int32, ParameterDirection.Input); paramArr[6] = Utilities.GetOraParam(":P_TRFD_SEQ", var.TransSEQ, OracleDbType.Int32, ParameterDirection.InputOutput); paramArr[7] = Utilities.GetOraParam(":P_DECISION_DATE", var.DecisionDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArr[8] = Utilities.GetOraParam(":P_TRFD_DATE", var.TransDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArr[9] = Utilities.GetOraParam(":P_TRFD_VIA", var.TransVia, OracleDbType.Int32, ParameterDirection.Input); paramArr[10] = Utilities.GetOraParam(":P_TRFD_RCVD_BY", var.TransRecvBy, OracleDbType.Int32, ParameterDirection.Input); paramArr[11] = Utilities.GetOraParam(":P_TRFD_ORG_UNIT", var.TransOrgUnit, OracleDbType.Int32, ParameterDirection.Input); paramArr[12] = Utilities.GetOraParam(":P_TRFD_TO", var.TransTo, OracleDbType.Int32, ParameterDirection.Input); paramArr[13] = Utilities.GetOraParam(":P_TRFD_RCVD_DATE", var.TransRecvDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArr[14] = Utilities.GetOraParam(":P_RETURN_BY", var.ReturnBy, OracleDbType.Int32, ParameterDirection.Input); paramArr[15] = Utilities.GetOraParam(":P_RETURN_DATE", var.ReturnDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArr[16] = Utilities.GetOraParam(":P_RETURN_VIA", var.ReturnVia, OracleDbType.Int32, ParameterDirection.Input); paramArr[17] = Utilities.GetOraParam(":P_RETURN_RCVD_BY", var.ReturnRecvBy, OracleDbType.Int32, ParameterDirection.Input); paramArr[18] = Utilities.GetOraParam(":P_RETURN_RCVD_DATE", var.ReturnRecvDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArr[19] = Utilities.GetOraParam(":P_ENTRY_BY", var.EntryBy, OracleDbType.Varchar2, ParameterDirection.Input); SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, InsertUpdateItemsTransfered, paramArr); var.TransSEQ = int.Parse(paramArr[6].Value.ToString()); } } } } } catch (Exception ex) { Tran.Rollback(); throw ex; } Tran.Commit(); return(true); }
/// <summary> /// Commit changes to the database. /// </summary> public void Commit() { Tran.Commit(); }
public static bool AddProgram(ATTProgram objProgram) { string InsertUpdateSP = ""; OracleTransaction Tran; if (objProgram.Action == "A") { InsertUpdateSP = "SP_ADD_PROGRAM"; } else if (objProgram.Action == "E") { InsertUpdateSP = "SP_EDIT_PROGRAM"; } int?durationTypeID; if (objProgram.DurationTypeID == 0) { durationTypeID = null; } else { durationTypeID = objProgram.DurationTypeID; } OracleParameter[] paramArray = new OracleParameter[11]; paramArray[0] = Utilities.GetOraParam(":p_ORG_ID", objProgram.OrgID, OracleDbType.Int64, ParameterDirection.Input); paramArray[1] = Utilities.GetOraParam(":p_PROGRAM_ID", objProgram.ProgramID, OracleDbType.Int64, ParameterDirection.InputOutput); paramArray[2] = Utilities.GetOraParam(":p_PROGRAM_NAME", objProgram.ProgramName, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[3] = Utilities.GetOraParam(":p_PROGRAM_TYPE_ID", objProgram.ProgramTypeID, OracleDbType.Int64, ParameterDirection.Input); paramArray[4] = Utilities.GetOraParam(":p_DESCRIPTION", objProgram.Description, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[5] = Utilities.GetOraParam(":p_ACTIVE", objProgram.Active, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[6] = Utilities.GetOraParam(":p_LAUNCH_DATE", objProgram.LaunchDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[7] = Utilities.GetOraParam(":p_DURATION", objProgram.Duration, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[8] = Utilities.GetOraParam(":p_DURATION_TYPE_ID", durationTypeID, OracleDbType.Int64, ParameterDirection.Input); paramArray[9] = Utilities.GetOraParam(":p_TO_DATE", objProgram.ToDate, OracleDbType.Varchar2, ParameterDirection.Input); paramArray[10] = Utilities.GetOraParam(":p_LOCATION", objProgram.Location, OracleDbType.Varchar2, ParameterDirection.Input); GetConnection GetConn = new GetConnection(); OracleConnection DBConn = GetConn.GetDbConn(Module.DLPDS); Tran = DBConn.BeginTransaction(); try { SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, InsertUpdateSP, paramArray); objProgram.ProgramID = int.Parse(paramArray[1].Value.ToString()); if (objProgram.PrgCoordinatorLST != null) { DLLProgramCoordinator.AddProgramCoordinator(objProgram.PrgCoordinatorLST, objProgram.ProgramID, Tran); } if (objProgram.PrgSponsorLST != null) { DLLProgramSponsor.AddProgramSponsor(objProgram.PrgSponsorLST, objProgram.ProgramID, Tran); } if (objProgram.SessionLST != null) { DLLSession.AddSession(objProgram.SessionLST, objProgram.ProgramID, Tran); } if (objProgram.CourseLST != null) { DLLCourse.AddCourse(objProgram.CourseLST, objProgram.ProgramID, Tran); } Tran.Commit(); return(true); } catch (Exception ex) { Tran.Rollback(); throw ex; } finally { GetConn.CloseDbConn(); } }
private void btnCSave_Click(object sender, EventArgs e) { // 선택된 행 데이터 저장 if (dgvCGrid.Rows.Count == 0) { return; } if (MessageBox.Show("선택된 데이터를 등록 하시겠습니까?", "데이터 등록", MessageBoxButtons.YesNo) == DialogResult.No) { return; } string sCustCode = dgvCGrid.CurrentRow.Cells["CUSTCODE"].Value.ToString(); string sCustType = dgvCGrid.CurrentRow.Cells["CUSTTYPE"].Value.ToString(); string sCustName = dgvCGrid.CurrentRow.Cells["CUSTNAME"].Value.ToString(); string sBIZCLASS = dgvCGrid.CurrentRow.Cells["BIZCLASS"].Value.ToString(); string sBIZTYPE = dgvCGrid.CurrentRow.Cells["BIZTYPE"].Value.ToString(); string sFIRSTDATE = dgvCGrid.CurrentRow.Cells["FIRSTDATE"].Value.ToString(); string sUSEFLAG = dgvCGrid.CurrentRow.Cells["USEFLAG"].Value.ToString(); if ((sCustCode.ToString() == "") || (sCustType.ToString() == "") || (sFIRSTDATE.ToString() == "")) { MessageBox.Show("전부 기입 하시오"); return; } if (sCustType == "고객사") { sCustType = "C"; } else if (sCustType == "협력사") { sCustType = "V"; } else { sCustType = "C"; } if (sUSEFLAG == "사용") { sUSEFLAG = "Y"; } else if (sUSEFLAG == "미사용") { sUSEFLAG = "N"; } else { sUSEFLAG = "Y"; } SqlCommand cmd = new SqlCommand(); SqlTransaction Tran; Connect = new SqlConnection(strCon); Connect.Open(); //트랜잭션 설정 Tran = Connect.BeginTransaction("CUSTTran"); cmd.Transaction = Tran; cmd.Connection = Connect; cmd.CommandText = "UPDATE TB_CUST_KHU " + // 코드와 타입은 업데이트하면 안되니 SET에서 지움. 그리고 where에 작성 " SET CUSTNAME = '" + sCustName + "', " + " BIZCLASS = '" + sBIZCLASS + "', " + " BIZTYPE = '" + sBIZTYPE + "', " + " USEFLAG = '" + sUSEFLAG + "', " + " FIRSTDATE = '" + sFIRSTDATE + "', " + " EDITOR = '" + Common.LoginID + "', " + " EDITDATE = GETDATE() " + " WHERE CUSTCODE = '" + sCustCode + "'" + " AND CUSTTYPE = '" + sCustType + "'" + " IF (@@ROWCOUNT =0) " + "INSERT INTO TB_CUST_KHU(CUSTCODE, CUSTTYPE, CUSTNAME, BIZCLASS, BIZTYPE, USEFLAG, FIRSTDATE, MAKEDATE, MAKER) " + "VALUES('" + sCustCode + "','" + sCustType + "','" + sCustName + "','" + sBIZCLASS + "', '" + sBIZTYPE + "', '" + sUSEFLAG + "','" + sFIRSTDATE + "',GETDATE(),'" + Common.LoginID + "')"; cmd.ExecuteNonQuery(); // 성공 시 DB COMMIT Tran.Commit(); MessageBox.Show("정상적으로 등록 하였습니다."); Connect.Close(); }
public void CommitTransaction() { Tran.Commit(); }