コード例 #1
0
ファイル: Memo.cs プロジェクト: kimykunjun/test
        public bool SaveNewMemo(string strTitle, string strMessage, string strImgPath, string strFilePath1, string strFilePath2, string strFilePath3, int nEmployeeID, MemoStatusID aMemoStatus, DataTable dtBranch,
			DataTable dtDepartment, DataTable dtGroup, DataTable dtEmployee)
        {
            SqlConnection con = new SqlConnection(SqlHelperUtils.connectionString);
            SqlTransaction tran = null;
            SqlParameter paramErrorCode = new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, new Int32());

            try
            {
                con.Open();
                tran = con.BeginTransaction();
                int nMemoID = 0;
                nMemoID = (int)SqlHelper.ExecuteScalar(tran, "pr_tblMemo_Insert", new SqlParameter("@sstrTitle", strTitle),
                    new SqlParameter("@sstrMessage", strMessage), new SqlParameter("@sstrImgPath", strImgPath), new SqlParameter("@sstrFilePath1", strFilePath1), new SqlParameter("@sstrFilePath2", strFilePath2), new SqlParameter("@sstrFilePath3", strFilePath3), new SqlParameter("@inEmployeeID", nEmployeeID),
                    new SqlParameter("@inStatusID", ((int)aMemoStatus)));

                foreach (DataRow row in dtBranch.Select())
                {
                    SqlHelper.ExecuteNonQuery(tran, "sp_tblMemoBranch_Insert", new SqlParameter("@inMemoID", nMemoID),
                        new SqlParameter("@sstrBranchCode", row["strBranchCode"].ToString()), paramErrorCode);
                }
                foreach (DataRow row in dtDepartment.Select())
                {
                    SqlHelper.ExecuteNonQuery(tran, "sp_tblMemoReceipient_Insert",
                        new SqlParameter("@inTypeID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, 1),
                        new SqlParameter("@inReceipientID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, Convert.ToInt32(row["nMemoGroupID"])),
                        new SqlParameter("@inMemoID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, nMemoID),
                        paramErrorCode);
                }
                foreach (DataRow row in dtGroup.Select())
                {
                    SqlHelper.ExecuteNonQuery(tran, "sp_tblMemoReceipient_Insert",
                        new SqlParameter("@inTypeID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, 1),
                        new SqlParameter("@inReceipientID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, Convert.ToInt32(row["nMemoGroupID"])),
                        new SqlParameter("@inMemoID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, nMemoID),
                        paramErrorCode);
                }
                foreach (DataRow row in dtEmployee.Select())
                {
                    SqlHelper.ExecuteNonQuery(tran, "sp_tblMemoReceipient_Insert",
                        new SqlParameter("@inTypeID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, 0),
                        new SqlParameter("@inReceipientID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, Convert.ToInt32(row["nEmployeeID"])),
                        new SqlParameter("@inMemoID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, nMemoID),
                        paramErrorCode);
                }

                tran.Commit();
                return true;
            }
            catch//(Exception ex)
            {
                if (tran != null)
                    tran.Rollback();
                throw;
            }
            finally
            {
                con.Close();
                con.Dispose();
            }
        }
コード例 #2
0
ファイル: Memo.cs プロジェクト: kimykunjun/test
        public bool SaveNewMemo(string strTitle, string strMessage, string strImgPath, string strFilePath1, string strFilePath2, string strFilePath3, int nEmployeeID, MemoStatusID aMemoStatus, DataTable dtBranch,
                                DataTable dtDepartment, DataTable dtGroup, DataTable dtEmployee)
        {
            SqlConnection  con            = new SqlConnection(SqlHelperUtils.connectionString);
            SqlTransaction tran           = null;
            SqlParameter   paramErrorCode = new SqlParameter("@iErrorCode", SqlDbType.Int, 4, ParameterDirection.Output, true, 10, 0, "", DataRowVersion.Proposed, new Int32());

            try
            {
                con.Open();
                tran = con.BeginTransaction();
                int nMemoID = 0;
                nMemoID = (int)SqlHelper.ExecuteScalar(tran, "pr_tblMemo_Insert", new SqlParameter("@sstrTitle", strTitle),
                                                       new SqlParameter("@sstrMessage", strMessage), new SqlParameter("@sstrImgPath", strImgPath), new SqlParameter("@sstrFilePath1", strFilePath1), new SqlParameter("@sstrFilePath2", strFilePath2), new SqlParameter("@sstrFilePath3", strFilePath3), new SqlParameter("@inEmployeeID", nEmployeeID),
                                                       new SqlParameter("@inStatusID", ((int)aMemoStatus)));

                foreach (DataRow row in dtBranch.Select())
                {
                    SqlHelper.ExecuteNonQuery(tran, "sp_tblMemoBranch_Insert", new SqlParameter("@inMemoID", nMemoID),
                                              new SqlParameter("@sstrBranchCode", row["strBranchCode"].ToString()), paramErrorCode);
                }
                foreach (DataRow row in dtDepartment.Select())
                {
                    SqlHelper.ExecuteNonQuery(tran, "sp_tblMemoReceipient_Insert",
                                              new SqlParameter("@inTypeID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, 1),
                                              new SqlParameter("@inReceipientID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, Convert.ToInt32(row["nMemoGroupID"])),
                                              new SqlParameter("@inMemoID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, nMemoID),
                                              paramErrorCode);
                }
                foreach (DataRow row in dtGroup.Select())
                {
                    SqlHelper.ExecuteNonQuery(tran, "sp_tblMemoReceipient_Insert",
                                              new SqlParameter("@inTypeID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, 1),
                                              new SqlParameter("@inReceipientID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, Convert.ToInt32(row["nMemoGroupID"])),
                                              new SqlParameter("@inMemoID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, nMemoID),
                                              paramErrorCode);
                }
                foreach (DataRow row in dtEmployee.Select())
                {
                    SqlHelper.ExecuteNonQuery(tran, "sp_tblMemoReceipient_Insert",
                                              new SqlParameter("@inTypeID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, 0),
                                              new SqlParameter("@inReceipientID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, Convert.ToInt32(row["nEmployeeID"])),
                                              new SqlParameter("@inMemoID", SqlDbType.Int, 4, ParameterDirection.Input, false, 10, 0, "", DataRowVersion.Proposed, nMemoID),
                                              paramErrorCode);
                }

                tran.Commit();
                return(true);
            }
            catch            //(Exception ex)
            {
                if (tran != null)
                {
                    tran.Rollback();
                }
                throw;
            }
            finally
            {
                con.Close();
                con.Dispose();
            }
        }